List of usage examples for org.apache.poi.ss.usermodel CellStyle setAlignment
void setAlignment(HorizontalAlignment align);
From source file:controller.VisitasController.java
public void centerRow(Workbook wb, Row row) { CellStyle style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); for (int i = 0; i < row.getLastCellNum(); i++) { if (row.getCell(i) != null) { row.getCell(i).setCellStyle(style);//Set the sty;e }/* w ww. j a v a 2s . c o m*/ } }
From source file:Dao.XlsBillDao.java
public void GenFullXLS(String pono, String relpath) { try {/*from www . j a v a2 s .co m*/ //0.Declare Variables for Sheet //DB Variable // pono = "WO/2015/2005"; //XLS Variable XSSFSheet spreadsheet; XSSFWorkbook workbook; XSSFRow row; XSSFCell cell; XSSFFont xfont = null; XSSFCellStyle xstyle = null; //1.Get Connection and Fetch Data ArrayList<WorkItemBean> wi1 = new ArrayList<WorkItemBean>(); WorkDao wdao1 = new WorkDao(); wi1 = wdao1.getWOItem(pono); //2.Create WorkBook and Sheet workbook = new XSSFWorkbook(); spreadsheet = workbook.createSheet("WorkOrder Detail"); // spreadsheet.protectSheet("kandarpCBA"); // spreadsheet.setColumnWidth(0, 255); //set header style xfont = workbook.createFont(); xfont.setFontHeight(11); xfont.setFontName("Calibri"); xfont.setBold(true); //Set font into style CellStyle borderStyle = workbook.createCellStyle(); borderStyle.setAlignment(CellStyle.ALIGN_CENTER); borderStyle.setFont(xfont); xstyle = workbook.createCellStyle(); xstyle.setFont(xfont); //header row = spreadsheet.createRow(0); cell = row.createCell(0); cell.setCellValue("WORK ORDER NO : " + pono); cell.setCellStyle(borderStyle); spreadsheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 5)); //3.Get First Row and Set Headers row = spreadsheet.createRow(1); cell = row.createCell(0); cell.setCellValue("LINE_NO"); cell.setCellStyle(xstyle); cell = row.createCell(1); cell.setCellValue("ITEM_ID"); cell.setCellStyle(xstyle); cell = row.createCell(2); cell.setCellValue("DESCRIPTION"); cell.setCellStyle(xstyle); cell = row.createCell(3); cell.setCellValue("UOM"); cell.setCellStyle(xstyle); cell = row.createCell(4); cell.setCellValue("QTY"); cell.setCellStyle(xstyle); cell = row.createCell(5); cell.setCellValue("RATE"); cell.setCellStyle(xstyle); cell = row.createCell(6); cell.setCellValue("NOTE"); cell.setCellStyle(xstyle); int i = 2; for (WorkItemBean w : wi1) { row = spreadsheet.createRow(i); cell = row.createCell(0); cell.setCellValue(w.getLINE_NO()); cell = row.createCell(1); cell.setCellValue(w.getITEM_ID()); cell = row.createCell(2); cell.setCellValue(w.getITEM_DESC()); cell = row.createCell(3); cell.setCellValue(w.getUOM()); cell = row.createCell(4); cell.setCellValue(w.getQTY()); cell = row.createCell(5); cell.setCellValue(w.getRATE()); cell = row.createCell(6); cell.setCellValue(w.getCMT()); i++; } //Export to Excel // FileOutputStream out = new FileOutputStream(new File("D://" + pono.replace("/", "-") + "_Items" + ".xlsx")); FileOutputStream out = new FileOutputStream( new File(relpath + "uxls//" + pono.replace("/", "-") + "_Items" + ".xlsx")); workbook.write(out); out.close(); Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "DONE|!"); Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "{0}uxls//{1}" + "_Items" + ".xlsx", new Object[] { relpath, pono.replace("/", "-") }); } catch (FileNotFoundException ex) { Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "Exception : {0}", ex); } catch (IOException ex) { Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "Exception : {0}", ex); } }
From source file:Dao.XlsBillDao.java
public void GenXLS(String pono, String relpath) { try {//from w w w. ja va2s . c o m //0.Declare Variables for Sheet //DB Variable // pono = "WO/2015/2005"; String sql; Connection con; PreparedStatement ps; ResultSet rs; //XLS Variable XSSFSheet spreadsheet; XSSFWorkbook workbook; XSSFRow row; XSSFCell cell; XSSFFont xfont = null; XSSFCellStyle xstyle = null; //1.Get Connection and Fetch Data con = DBmanager.GetConnection(); sql = "SELECT DISTINCT cba_wo_item.line_no, cba_wo_item.item_id,\n" + " mtl_system_items.description, cba_wo_item.uom,\n" + " cba_wo_item.qty, cba_wo_item.rate, cba_wo_item.cmt,\n" + " cba_wo_item.plant, cba_wo_item.proj, cba_wo_item.task," + " cba_wo_item.po_no\n" + " FROM cba_wo_item, mtl_system_items\n" + " WHERE ( (cba_wo_item.item_id = mtl_system_items.segment1)\n" + " AND (mtl_system_items.organization_id = 0)\n" + " AND (cba_wo_item.po_no = '" + pono + "')\n" + " )\n" + " ORDER BY cba_wo_item.line_no"; ps = con.prepareStatement(sql); rs = ps.executeQuery(); //2.Create WorkBook and Sheet workbook = new XSSFWorkbook(); spreadsheet = workbook.createSheet("WorkOrder Detail"); //spreadsheet.protectSheet("kandarpCBA"); //spreadsheet.setColumnWidth(0, 255); //set header style xfont = workbook.createFont(); xfont.setFontHeight(11); xfont.setFontName("Calibri"); xfont.setBold(true); //Set font into style CellStyle borderStyle = workbook.createCellStyle(); borderStyle.setAlignment(CellStyle.ALIGN_CENTER); borderStyle.setFont(xfont); // borderStyle.setFillBackgroundColor(IndexedColors.GREEN.getIndex()); // borderStyle.setFillPattern(CellStyle.ALIGN_FILL); xstyle = workbook.createCellStyle(); xstyle.setFont(xfont); //header row = spreadsheet.createRow(0); cell = row.createCell(0); cell.setCellValue("WORK ORDER NO : " + pono + " Note : If WO is with project information,each bill item should have project and task"); cell.setCellStyle(borderStyle); spreadsheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 9)); //3.Get First Row and Set Headers row = spreadsheet.createRow(1); cell = row.createCell(0); cell.setCellValue("LINE_NO"); cell.setCellStyle(xstyle); cell = row.createCell(1); cell.setCellValue("ITEM_ID"); cell.setCellStyle(xstyle); cell = row.createCell(2); cell.setCellValue("DESCRIPTION"); cell.setCellStyle(xstyle); cell = row.createCell(3); cell.setCellValue("UOM"); cell.setCellStyle(xstyle); cell = row.createCell(4); cell.setCellValue("QTY"); cell.setCellStyle(xstyle); cell = row.createCell(5); cell.setCellValue("RATE"); cell.setCellStyle(xstyle); cell = row.createCell(6); cell.setCellValue("WO NOTE"); cell.setCellStyle(xstyle); cell = row.createCell(7); cell.setCellValue("PLANT"); cell.setCellStyle(xstyle); cell = row.createCell(8); cell.setCellValue("COST CENTER"); cell.setCellStyle(xstyle); cell = row.createCell(9); cell.setCellValue("PROJECT"); cell.setCellStyle(xstyle); cell = row.createCell(10); cell.setCellValue("TASK"); cell.setCellStyle(xstyle); cell = row.createCell(11); cell.setCellValue("HERE ADD NOTE"); cell.setCellStyle(xstyle); //Itrate or Database data and write int i = 2; while (rs.next()) { row = spreadsheet.createRow(i); cell = row.createCell(0); cell.setCellValue(rs.getString(1)); cell = row.createCell(1); cell.setCellValue(rs.getString(2)); cell = row.createCell(2); cell.setCellValue(rs.getString(3)); cell = row.createCell(3); cell.setCellValue(rs.getString(4)); cell = row.createCell(4); cell.setCellValue(rs.getString(6)); cell = row.createCell(5); cell.setCellValue(rs.getString(5)); cell = row.createCell(6); cell.setCellValue(""); cell = row.createCell(7); cell.setCellValue(rs.getString(7)); cell = row.createCell(8); cell.setCellValue(rs.getString(8)); cell = row.createCell(9); cell.setCellValue(rs.getString(9)); cell = row.createCell(10); cell.setCellValue(rs.getString(10)); cell = row.createCell(11); cell.setCellValue(""); i++; } //SECOND WORKSHEET FOR COST CENTER AND PLANT DETAIL XSSFRow row2; XSSFCell cell2; XSSFSheet ccsheet = workbook.createSheet("Cost Center"); row2 = ccsheet.createRow(0); cell2 = row2.createCell(0); cell2.setCellValue("Cost Center name and code. Please enter only code in excel"); cell2.setCellStyle(borderStyle); ccsheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 9)); row2 = ccsheet.createRow(1); cell2 = row2.createCell(0); cell2.setCellValue("CODE"); cell2.setCellStyle(xstyle); cell2 = row2.createCell(1); cell2.setCellValue("NAME"); cell2.setCellStyle(xstyle); con = DBmanager.GetConnection(); sql = "select cc,plant from cba_cc_mst"; ps = con.prepareStatement(sql); rs = ps.executeQuery(); int i2 = 2; while (rs.next()) { row2 = ccsheet.createRow(i2); cell2 = row2.createCell(0); cell2.setCellValue(rs.getString(1)); cell2 = row2.createCell(1); cell2.setCellValue(rs.getString(2)); i2++; } //THIRD SHEET //SECOND WORKSHEET FOR COST CENTER AND PLANT DETAIL XSSFRow row3; XSSFCell cell3; XSSFSheet plantsheet = workbook.createSheet("Plant Center"); row3 = plantsheet.createRow(0); cell3 = row3.createCell(0); cell3.setCellValue("Plant Center name and code. Please enter only code in excel"); cell3.setCellStyle(borderStyle); plantsheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 9)); row3 = plantsheet.createRow(1); cell3 = row3.createCell(0); cell3.setCellValue("CODE"); cell3.setCellStyle(xstyle); cell3 = row3.createCell(1); cell3.setCellValue("NAME"); cell3.setCellStyle(xstyle); con = DBmanager.GetConnection(); sql = "select cc,plant from cba_plant_mst"; ps = con.prepareStatement(sql); rs = ps.executeQuery(); int i3 = 2; while (rs.next()) { row3 = plantsheet.createRow(i3); cell3 = row3.createCell(0); cell3.setCellValue(rs.getString(1)); cell3 = row3.createCell(1); cell3.setCellValue(rs.getString(2)); i3++; } //SHEET 3 HEADER //row1 XSSFSheet spreadsheet4 = workbook.createSheet("Project And Task"); XSSFRow row4 = spreadsheet4.createRow(0); XSSFCell cell4 = row4.createCell(0); cell4.setCellValue("Note : Please copy project,task code and paste into 1 sheet"); spreadsheet4.addMergedRegion(new CellRangeAddress(0, 0, 0, 5)); //row2 row4 = spreadsheet4.createRow(1); cell4 = row4.createCell(0); cell4.setCellValue("PROJECT CODE"); cell4.setCellStyle(xstyle); cell4 = row4.createCell(1); cell4.setCellValue("PROJECT NAME"); cell4.setCellStyle(xstyle); cell4 = row4.createCell(2); cell4.setCellValue("TASK CODE"); cell4.setCellStyle(xstyle); //SHEET 3 DATA int j = 2; ArrayList<WorkItemBean> wi1 = Dropdown.LoadProjTaskMst("123"); for (WorkItemBean w : wi1) { row4 = spreadsheet4.createRow(j); cell4 = row4.createCell(0); cell4.setCellValue(w.getPROJ()); cell4 = row4.createCell(1); cell4.setCellValue(w.getPROJ_NAME()); cell4 = row4.createCell(2); cell4.setCellValue(w.getTASK()); j++; } //Export to Excel // FileOutputStream out = new FileOutputStream(new File("D://" + pono.replace("/", "-") + ".xlsx")); FileOutputStream out = new FileOutputStream( new File(relpath + "xls//" + pono.replace("/", "-") + ".xlsx")); workbook.write(out); out.close(); Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "DONE|!"); Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "{0}xls//{1}.xlsx", new Object[] { relpath, pono.replace("/", "-") }); } catch (SQLException ex) { Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "Exception : {0}", ex); } catch (IOException ex) { Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "Exception : {0}", ex); } }
From source file:Dao.XlsWoDao.java
public void GenXLS(String orgId, String relpath) { try {//from w w w .j a v a 2 s .c om //2.Create WorkBook and Sheet XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet spreadsheet1 = workbook.createSheet("WorkOrder Detail"); XSSFSheet spreadsheet2 = workbook.createSheet("Plant Master"); XSSFSheet spreadsheet3 = workbook.createSheet("Project and Task Master"); //style XSSFFont xfont = workbook.createFont(); xfont.setFontHeight(11); xfont.setFontName("Calibri"); xfont.setBold(true); //Set font into style CellStyle borderStyle = workbook.createCellStyle(); borderStyle.setAlignment(CellStyle.ALIGN_CENTER); borderStyle.setFont(xfont); XSSFCellStyle xstyle = workbook.createCellStyle(); xstyle.setFont(xfont); //SHEET 1 HEADER //1row XSSFRow row1 = spreadsheet1.createRow(0); XSSFCell cell1 = row1.createCell(0); cell1.setCellValue("Note : If you are not sure " + "about plant,project,task please " + "leave it blank." + "It can be add when release bill"); spreadsheet1.addMergedRegion(new CellRangeAddress(0, 0, 0, 15)); //2row row1 = spreadsheet1.createRow(1); cell1 = row1.createCell(0); cell1.setCellValue("Create Work Order Template"); cell1.setCellStyle(borderStyle); spreadsheet1.addMergedRegion(new CellRangeAddress(1, 1, 0, 4)); //3row row1 = spreadsheet1.createRow(2); cell1 = row1.createCell(0); cell1.setCellValue("ITEM_NO"); cell1.setCellStyle(xstyle); cell1 = row1.createCell(1); cell1.setCellValue("RATE"); cell1.setCellStyle(xstyle); cell1 = row1.createCell(2); cell1.setCellValue("PLANT"); cell1.setCellStyle(xstyle); cell1 = row1.createCell(3); cell1.setCellValue("PROJECT"); cell1.setCellStyle(xstyle); cell1 = row1.createCell(4); cell1.setCellValue("TASK"); cell1.setCellStyle(xstyle); cell1 = row1.createCell(5); cell1.setCellValue("ADDITIONAL NOTE"); cell1.setCellStyle(xstyle); //SHEET 2 HEADER //row1 XSSFRow row2 = spreadsheet2.createRow(0); XSSFCell cell2 = row2.createCell(0); cell2.setCellValue("Note : Please copy plant code and paste into 1 sheet"); spreadsheet2.addMergedRegion(new CellRangeAddress(0, 0, 0, 5)); //row2 row2 = spreadsheet2.createRow(1); cell2 = row2.createCell(0); cell2.setCellValue("PLANT_CODE"); cell2.setCellStyle(xstyle); cell2 = row2.createCell(1); cell2.setCellValue("PLANT NAME"); cell2.setCellStyle(xstyle); //SHEET 2 DATA int i = 2; Map<String, String> plant = Dropdown.LoadPlantMst(); for (Map.Entry<String, String> entry : plant.entrySet()) { row2 = spreadsheet2.createRow(i); cell2 = row2.createCell(0); cell2.setCellValue(entry.getKey()); cell2 = row2.createCell(1); cell2.setCellValue(entry.getValue()); i++; } //SHEET 3 HEADER //row1 XSSFRow row3 = spreadsheet3.createRow(0); XSSFCell cell3 = row3.createCell(0); cell3.setCellValue("Note : Please copy project,task code and paste into 1 sheet"); spreadsheet3.addMergedRegion(new CellRangeAddress(0, 0, 0, 5)); //row2 row3 = spreadsheet3.createRow(1); cell3 = row3.createCell(0); cell3.setCellValue("PROJECT CODE"); cell3.setCellStyle(xstyle); cell3 = row3.createCell(1); cell3.setCellValue("PROJECT NAME"); cell3.setCellStyle(xstyle); cell3 = row3.createCell(2); cell3.setCellValue("TASK CODE"); cell3.setCellStyle(xstyle); //SHEET 3 DATA int j = 2; ArrayList<WorkItemBean> wi1 = Dropdown.LoadProjTaskMst(orgId); for (WorkItemBean w : wi1) { row3 = spreadsheet3.createRow(j); cell3 = row3.createCell(0); cell3.setCellValue(w.getPROJ()); cell3 = row3.createCell(1); cell3.setCellValue(w.getPROJ_NAME()); cell3 = row3.createCell(2); cell3.setCellValue(w.getTASK()); j++; } //Export to Excel // FileOutputStream out = new FileOutputStream(new File("D://" + pono.replace("/", "-") + "_Items" + ".xlsx")); // FileOutputStream out = new FileOutputStream(new File(relpath + "uxls//" + "WO_Creation_Template" + ".xlsx")); FileOutputStream out = new FileOutputStream(new File(relpath)); workbook.write(out); out.close(); Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "DONE|!"); } catch (FileNotFoundException ex) { Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "Exception : {0}", ex); } catch (IOException ex) { Logger.getLogger(XlsBillDao.class.getName()).log(Level.SEVERE, "Exception : {0}", ex); } }
From source file:Data.Database.java
public void dumpExcel() throws FileNotFoundException, IOException { //Workbook wb = new HSSFWorkbook(); Workbook wb = new XSSFWorkbook(); CreationHelper createHelper = wb.getCreationHelper(); Sheet sheet = wb.createSheet("leaguedata"); // set headers on excel sheet Row row = sheet.createRow((short) 0); String headers[] = new String[] { "Team", "Player", "Position", "Age", "Yrs Played", "GP", "G", "A", "PTS", "+/-", "STP", "SOG", "SH%", "Hits", "Blocks", "TOI", "G/60", "A/60", "PTS/60", "STP/60", "SOG/60", "Hits/60", "Blocks/60" }; for (int i = 0; i < headers.length; i++) { Cell cell = row.createCell(i);// w ww.j av a 2 s.c om cell.setCellValue(createHelper.createRichTextString(headers[i])); CellStyle cellStyle = wb.createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_CENTER); cell.setCellStyle(cellStyle); } // add player data int track = 2; // // dump ALL players!!!!! // for (Map.Entry<String, Player> entry : players.entrySet()){ // Row newrow = sheet.createRow((short)track); // entry.getValue().dumpExcel(newrow, "null"); // track++; // } // // // Write the output to a file // FileOutputStream fileOut = new FileOutputStream("RFHL_allplayers.xlsx"); // wb.write(fileOut); // fileOut.close(); // dump fantasy teams!!! for (int i = 0; i < fh_teams.size(); i++) { track = fh_teams.get(i).dumpExcel(sheet, track); track++; } // Write the output to a file FileOutputStream fileOut = new FileOutputStream("RFHL.xlsx"); wb.write(fileOut); fileOut.close(); }
From source file:dataQuality.checkDuplicates.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException { session = request.getSession();/*w ww . jav a 2s. c om*/ dbConn conn = new dbConn(); i = 4; // ^^^^^^^^^^^^^CREATE STATIC AND WRITE STATIC DATA TO THE EXCELL^^^^^^^^^^^^ HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet shet1 = wb.createSheet(); HSSFFont font = wb.createFont(); font.setFontHeightInPoints((short) 18); font.setFontName("Arial Black"); // font.setItalic(true); // font.setBoldweight((short)12); font.setColor((short) 0000); CellStyle style = wb.createCellStyle(); style.setFont(font); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFFont font2 = wb.createFont(); // font2.setFontHeightInPoints((short)15); font2.setFontName("Arial Black"); // font.setItalic(true); // font2.setBoldweight((short)18); font2.setColor((short) 0000); CellStyle style2 = wb.createCellStyle(); style2.setFont(font2); HSSFCellStyle stborder = wb.createCellStyle(); stborder.setBorderTop(HSSFCellStyle.BORDER_THIN); stborder.setBorderBottom(HSSFCellStyle.BORDER_THIN); stborder.setBorderLeft(HSSFCellStyle.BORDER_THIN); stborder.setBorderRight(HSSFCellStyle.BORDER_THIN); // stborder.setFillForegroundColor(HSSFColor.ORANGE.index); // stborder.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); stborder.setAlignment(HSSFCellStyle.ALIGN_CENTER); // HSSFSheet sheet1 = wb.getSheetAt(0); shet1.setColumnWidth(0, 5000); shet1.setColumnWidth(1, 5000); shet1.setColumnWidth(2, 5000); shet1.setColumnWidth(3, 5500); shet1.setColumnWidth(4, 7000); shet1.setColumnWidth(5, 5300); shet1.setColumnWidth(6, 5000); shet1.setColumnWidth(7, 5200); shet1.setColumnWidth(8, 5200); shet1.setColumnWidth(9, 5200); shet1.setColumnWidth(10, 5800); shet1.setColumnWidth(11, 5000); // shet1.setColumnWidth(20, 2000); HSSFCellStyle styleBorder = wb.createCellStyle(); styleBorder.setBorderTop(HSSFCellStyle.BORDER_THIN); styleBorder.setBorderBottom(HSSFCellStyle.BORDER_THIN); styleBorder.setBorderLeft(HSSFCellStyle.BORDER_THIN); styleBorder.setBorderRight(HSSFCellStyle.BORDER_THIN); // styleBorder.setFillForegroundColor(HSSFColor.ORANGE.index); // styleBorder.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); styleBorder.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFRow rw1 = shet1.createRow(1); HSSFCell cell; HSSFRow rw4 = shet1.createRow(0); rw4.setHeightInPoints(45); rw4.setRowStyle(style2); HSSFCell cell1, cell2, cell3, cell4, cell5, cell6, cell7, cell8, cell9, cell10, cell11, cell12, cell13, cell14, cell15, cell16, cell17, cell18, cell19, cell20; cell1 = rw4.createCell(0); cell2 = rw4.createCell(1); cell3 = rw4.createCell(2); cell4 = rw4.createCell(3); cell5 = rw4.createCell(4); cell6 = rw4.createCell(5); cell7 = rw4.createCell(6); cell8 = rw4.createCell(7); cell9 = rw4.createCell(8); cell10 = rw4.createCell(9); cell11 = rw4.createCell(10); cell12 = rw4.createCell(11); cell13 = rw4.createCell(12); cell14 = rw4.createCell(13); cell1.setCellValue("COUNTY NAME"); cell2.setCellValue("PARTNER NAME"); cell3.setCellValue("DISTRICT"); cell4.setCellValue("FACILITY"); cell5.setCellValue("GROUP NAME"); cell6.setCellValue("CLIENT NAME"); cell7.setCellValue("AGE"); cell8.setCellValue("GENDER"); cell9.setCellValue("YEAR"); cell10.setCellValue("SESSION ATTENDED"); cell11.setCellValue("No. of duplicates"); cell11.setCellValue("SERVICE PROVIDER"); cell12.setCellValue("START DATE"); cell13.setCellValue("END DATE"); HSSFCellStyle stylex = wb.createCellStyle(); stylex.setFillForegroundColor(HSSFColor.LIME.index); stylex.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); stylex.setBorderTop(HSSFCellStyle.BORDER_THIN); stylex.setBorderBottom(HSSFCellStyle.BORDER_THIN); stylex.setBorderLeft(HSSFCellStyle.BORDER_THIN); stylex.setBorderRight(HSSFCellStyle.BORDER_THIN); stylex.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFFont fontx = wb.createFont(); fontx.setColor(HSSFColor.DARK_BLUE.index); stylex.setFont(fontx); stylex.setWrapText(true); cell1.setCellStyle(stylex); cell2.setCellStyle(stylex); cell3.setCellStyle(stylex); cell4.setCellStyle(stylex); cell5.setCellStyle(stylex); cell6.setCellStyle(stylex); cell7.setCellStyle(stylex); cell8.setCellStyle(stylex); cell9.setCellStyle(stylex); cell10.setCellStyle(stylex); cell11.setCellStyle(stylex); cell12.setCellStyle(stylex); cell13.setCellStyle(stylex); //cell14.setCellStyle(stylex); i = 1; String getClients = "SELECT * FROM clients ORDER BY fname"; conn.rs = conn.st.executeQuery(getClients); while (conn.rs.next()) { county = district = hf = partner = groupname = serviceprovider = clientname = age = gender = groupings = year = providerid = ""; countyid = districtid = hfid = partnerid = groupid = serviceproviderid = clientid = ""; sess = val = cds = duplicate = 0; startdate = enddate = ""; // System.out.println("here : "+i); HSSFRow rw4x = shet1.createRow(i); rw4.setHeightInPoints(45); rw4.setRowStyle(style2); // rw4.createCell(1).setCellValue("Number"); HSSFCell cell1x, cell2x, cell3x, cell4x, cell5x, cell6x, cell7x, cell8x, cell9x, cell10x, cell11x, cell12x, cell13x, cell14x, cell15x, cell16x, cell17x, cell18x, cell19x, cell20x; cell1x = rw4x.createCell(0); cell2x = rw4x.createCell(1); cell3x = rw4x.createCell(2); cell4x = rw4x.createCell(3); cell5x = rw4x.createCell(4); cell6x = rw4x.createCell(5); cell7x = rw4x.createCell(6); cell8x = rw4x.createCell(7); cell9x = rw4x.createCell(8); cell10x = rw4x.createCell(9); cell11x = rw4x.createCell(10); cell12x = rw4x.createCell(11); cell13x = rw4x.createCell(12); // cell14x=rw4x.createCell(13); providername = ""; clientid = conn.rs.getString(1); clientname = conn.rs.getString(2) + " " + conn.rs.getString(3) + " " + conn.rs.getString(4); age = conn.rs.getString(5); gender = conn.rs.getString(6); groupid = conn.rs.getString(7); groupings = conn.rs.getString(8); districtid = conn.rs.getString(9); partnerid = conn.rs.getString(10); year = conn.rs.getString(13); providerid = conn.rs.getString(14); if (conn.rs.getString(3).equals(conn.rs.getString(4))) { clientname = conn.rs.getString(2) + " " + conn.rs.getString(4); } cds = conn.rs.getInt("lessons_attended"); start_date = end_date = ""; String serviceprov = "SELECT fname,mname,lname FROM service_provider WHERE provider_id='" + providerid + "'"; conn.rs1 = conn.st1.executeQuery(serviceprov); if (conn.rs1.next()) { if (conn.rs1.getString(2).equals(conn.rs1.getString(3))) { providername = conn.rs1.getString(1) + " " + conn.rs.getString(3); } else { providername = conn.rs1.getString(1) + " " + conn.rs1.getString(2) + " " + conn.rs.getString(3); } } String checker = "SELECT COUNT(client_id) FROM clients WHERE fname=? && lname=? && client_id!=?"; conn.pst = conn.conn.prepareStatement(checker); conn.pst.setString(1, conn.rs.getString(2)); conn.pst.setString(2, conn.rs.getString(3)); // conn.pst.setString(3, conn.rs.getString(4)); conn.pst.setString(3, clientid); // conn.pst.setString(3, conn.rs.getString(2)); // conn.pst.setString(4, conn.rs.getString(3)); // conn.pst.setString(5, groupid); // conn.pst.setString(6, conn.rs.getString(2)); // conn.pst.setString(7, age); // conn.pst.setString(8, clientid); // conn.pst.setString(8, age); conn.rs1 = conn.pst.executeQuery(); found = 0; if (conn.rs1.next() == true) { found = conn.rs1.getInt(1); } System.out.println("found : " + found); if (found > 0) { duplicate = found; } if (found == 0) { duplicate = 0; } String getCnt = "SELECT district.district_name,county.county_name FROM district JOIN county ON district.county_id=county.county_id WHERE district.district_id='" + districtid + "'"; conn.rs1 = conn.st1.executeQuery(getCnt); if (conn.rs1.next() == true) { district = conn.rs1.getString(1); county = conn.rs1.getString(2); } String getPart = "SELECT partner_name FROM partner WHERE partner_id='" + partnerid + "'"; conn.rs1 = conn.st1.executeQuery(getPart); if (conn.rs1.next() == true) { partner = conn.rs1.getString(1); } if (!groupid.equals("0")) { String getgrp = "SELECT groups.group_name,health_facility.hf_name FROM groups JOIN health_facility ON groups.nhf_id=health_facility.hf_id" + " WHERE groups.group_id='" + groupid + "'"; conn.rs1 = conn.st1.executeQuery(getgrp); if (conn.rs1.next() == true) { groupname = conn.rs1.getString(1); hf = conn.rs1.getString(2); // SELECT START END DATE DATE FOR GROUP INDIVIDUALS---------------------------------------------- String getDates = "SELECT MAX(session_date),MIN(session_date) FROM sessions WHERE group_id='" + groupid + "' && session_date!=''"; conn.rs1 = conn.st1.executeQuery(getDates); if (conn.rs1.next() == true) { start_date = conn.rs1.getString(2); end_date = conn.rs1.getString(1); } } } if (groupid.equals("0")) { String getgrp1 = "SELECT health_facility.hf_name FROM no_group JOIN health_facility ON no_group.nhf_id=health_facility.hf_id" + " WHERE no_group.name='" + groupings + "'"; conn.rs1 = conn.st1.executeQuery(getgrp1); if (conn.rs1.next() == true) { groupname = "INDIVIDUAL"; hf = conn.rs1.getString(1); } String getDates = "SELECT MAX(session_date),MIN(session_date) FROM sessions WHERE groupings='" + groupings + "' && session_date!=''"; conn.rs1 = conn.st1.executeQuery(getDates); if (conn.rs1.next() == true) { start_date = conn.rs1.getString(2); end_date = conn.rs1.getString(1); } } // OUTPUT ATTENDED-------------------------------- if (duplicate > 0) { // OUTPUT SERVICES PROVIDED================================ cell1x.setCellValue(county); cell2x.setCellValue(partner); cell3x.setCellValue(district); cell4x.setCellValue(hf); cell5x.setCellValue(groupname); cell6x.setCellValue(clientname); cell7x.setCellValue(age); cell8x.setCellValue(gender); cell9x.setCellValue(year); cell10x.setCellValue(cds); // cell11x.setCellValue(duplicate); cell11x.setCellValue(providername); cell12x.setCellValue(start_date); cell13x.setCellValue(end_date); cell1x.setCellStyle(styleBorder); cell2x.setCellStyle(styleBorder); cell3x.setCellStyle(styleBorder); cell4x.setCellStyle(styleBorder); cell5x.setCellStyle(styleBorder); cell6x.setCellStyle(styleBorder); cell7x.setCellStyle(styleBorder); cell8x.setCellStyle(styleBorder); cell9x.setCellStyle(styleBorder); cell10x.setCellStyle(styleBorder); cell11x.setCellStyle(styleBorder); cell11x.setCellStyle(styleBorder); cell12x.setCellStyle(styleBorder); cell13x.setCellStyle(styleBorder); //cell14x.setCellStyle(styleBorder); i++; System.out.println("here : " + i); } } if (conn.rs != null) { conn.rs.close(); } if (conn.st != null) { conn.st.close(); } if (conn.rs1 != null) { conn.rs1.close(); } if (conn.st1 != null) { conn.st1.close(); } if (conn.rs2 != null) { conn.rs2.close(); } if (conn.st2 != null) { conn.st2.close(); } if (conn.st3 != null) { conn.st3.close(); } if (conn.pst != null) { conn.pst.close(); } if (conn.pst != null) { conn.pst.close(); } if (conn.pst1 != null) { conn.pst1.close(); } if (conn.pst1 != null) { conn.pst1.close(); } if (conn.conn != null) { conn.conn.close(); } // write it as an excel attachment ByteArrayOutputStream outByteStream = new ByteArrayOutputStream(); wb.write(outByteStream); byte[] outArray = outByteStream.toByteArray(); response.setContentType("application/ms-excel"); response.setContentLength(outArray.length); response.setHeader("Expires:", "0"); // eliminates browser caching response.setHeader("Content-Disposition", "attachment; filename=PWP_DUPLICATE_REPORT.xls"); OutputStream outStream = response.getOutputStream(); outStream.write(outArray); outStream.flush(); }
From source file:dataQuality.Syncer.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException { session = request.getSession();/* w w w .j a va 2 s .c om*/ dbConn conn = new dbConn(); String[] dater1 = request.getParameter("startdate").split("/"); String[] dater2 = request.getParameter("enddate").split("/"); String[] bydate = request.getParameter("bydate").split("/"); System.out.println("started"); datekey = bydate[2] + "" + bydate[1] + "" + bydate[0]; startdate = dater1[2] + "-" + dater1[1] + "-" + dater1[0]; enddate = dater2[2] + "-" + dater2[1] + "-" + dater2[0]; sdate = dater1[2] + "_" + dater1[1] + "_" + dater1[0]; ndate = dater2[2] + "_" + dater2[1] + "_" + dater2[0]; submissiondate = bydate[1] + "/" + bydate[0] + "/" + bydate[2]; System.out.println(submissiondate); // ^^^^^^^^^^^^^CREATE STATIC AND WRITE STATIC DATA TO THE EXCELL^^^^^^^^^^^^ HSSFWorkbook wb = new HSSFWorkbook(); // HSSFSheet shet1=wb.createSheet("Client Enrollments"); HSSFSheet shet2 = wb.createSheet("Session Attendance"); HSSFSheet shet3 = wb.createSheet("Services Provided"); HSSFFont font = wb.createFont(); font.setFontHeightInPoints((short) 18); font.setFontName("Arial Black"); font.setColor((short) 0000); CellStyle style = wb.createCellStyle(); style.setFont(font); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFFont font2 = wb.createFont(); font2.setFontName("Arial Black"); font2.setColor((short) 0000); CellStyle style2 = wb.createCellStyle(); style2.setFont(font2); HSSFCellStyle stborder = wb.createCellStyle(); stborder.setBorderTop(HSSFCellStyle.BORDER_THIN); stborder.setBorderBottom(HSSFCellStyle.BORDER_THIN); stborder.setBorderLeft(HSSFCellStyle.BORDER_THIN); stborder.setBorderRight(HSSFCellStyle.BORDER_THIN); stborder.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFCellStyle stylex = wb.createCellStyle(); stylex.setFillForegroundColor(HSSFColor.LIME.index); stylex.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); stylex.setBorderTop(HSSFCellStyle.BORDER_THIN); stylex.setBorderBottom(HSSFCellStyle.BORDER_THIN); stylex.setBorderLeft(HSSFCellStyle.BORDER_THIN); stylex.setBorderRight(HSSFCellStyle.BORDER_THIN); stylex.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFFont fontx = wb.createFont(); fontx.setColor(HSSFColor.DARK_BLUE.index); stylex.setFont(fontx); stylex.setWrapText(true); // // HSSFSheet sheet1 = wb.getSheetAt(0); // shet1.setColumnWidth(0, 4000); // shet1.setColumnWidth(1, 4000); // shet1.setColumnWidth(2, 4000); // shet1.setColumnWidth(3, 7500); // shet1.setColumnWidth(4, 7000); // shet1.setColumnWidth(5, 7300); // shet1.setColumnWidth(6, 2500); // shet1.setColumnWidth(7, 3200); // shet1.setColumnWidth(8, 4200); shet2.setColumnWidth(0, 4000); shet2.setColumnWidth(1, 4000); shet2.setColumnWidth(2, 4000); shet2.setColumnWidth(3, 6500); shet2.setColumnWidth(4, 7000); shet2.setColumnWidth(5, 7300); shet2.setColumnWidth(6, 2500); shet2.setColumnWidth(7, 3200); shet2.setColumnWidth(8, 4200); shet3.setColumnWidth(0, 4000); shet3.setColumnWidth(1, 4000); shet3.setColumnWidth(2, 4000); shet3.setColumnWidth(3, 6500); shet3.setColumnWidth(4, 7000); shet3.setColumnWidth(5, 7300); shet3.setColumnWidth(6, 2500); shet3.setColumnWidth(7, 3200); shet3.setColumnWidth(8, 4200); shet3.setColumnWidth(9, 4200); shet3.setColumnWidth(10, 4800); shet3.setColumnWidth(11, 4000); shet3.setColumnWidth(12, 4300); shet3.setColumnWidth(13, 4000); shet3.setColumnWidth(14, 4300); shet3.setColumnWidth(15, 4000); shet3.setColumnWidth(16, 4200); shet3.setColumnWidth(17, 4200); // HSSFRow rw4=shet1.createRow(0); // rw4.setHeightInPoints(45); // rw4.setRowStyle(style2); //// rw4.createCell(1).setCellValue("Number"); // HSSFCell cell0,cell1,cell2,cell3,cell4,cell5,cell6,cell7,cell8; // // cell0=rw4.createCell(0); // cell1=rw4.createCell(1); // cell2=rw4.createCell(2); // cell3=rw4.createCell(3); // cell4=rw4.createCell(4); // cell5=rw4.createCell(5); // cell6=rw4.createCell(6); // cell7=rw4.createCell(7); // cell8=rw4.createCell(8); // // // cell0 .setCellValue("County name"); // cell1.setCellValue("Partner name"); // cell2.setCellValue("District name"); // cell3.setCellValue("Group name"); // cell4.setCellValue("Service provider"); // cell5.setCellValue("Client name"); // cell6.setCellValue("Age"); // cell7.setCellValue("Gender"); // cell8.setCellValue("Timestamp"); // cell0 .setCellStyle(stylex); // cell1.setCellStyle(stylex); // cell2.setCellStyle(stylex); // cell3.setCellStyle(stylex); // cell4.setCellStyle(stylex); // cell5.setCellStyle(stylex); // cell6.setCellStyle(stylex); // cell7.setCellStyle(stylex); // cell8.setCellStyle(stylex); HSSFRow rw2m = shet2.createRow(0); rw2m.setHeightInPoints(45); rw2m.setRowStyle(style2); // rw4.createCell(1).setCellValue("Number"); HSSFCell cellm0, cellm1, cellm2, cellm3, cellm4, cellm5, cellm6, cellm7, cellm8, cellm9, cellm10, cellmk11; cellm0 = rw2m.createCell(0); cellm1 = rw2m.createCell(1); cellm2 = rw2m.createCell(2); cellm3 = rw2m.createCell(3); cellm4 = rw2m.createCell(4); cellm5 = rw2m.createCell(5); cellm6 = rw2m.createCell(6); cellm7 = rw2m.createCell(7); cellm8 = rw2m.createCell(8); cellm9 = rw2m.createCell(9); cellm10 = rw2m.createCell(10); cellmk11 = rw2m.createCell(11); cellm0.setCellValue("County name"); cellm1.setCellValue("Partner name"); cellm2.setCellValue("District name"); cellm3.setCellValue("Group name"); cellm4.setCellValue("Service provider"); cellm5.setCellValue("Client name"); cellm6.setCellValue("Age"); cellm7.setCellValue("Gender"); cellm8.setCellValue("Message"); cellm9.setCellValue("Status"); cellm10.setCellValue("Session Date"); cellmk11.setCellValue("Timestamp"); cellm0.setCellStyle(stylex); cellm1.setCellStyle(stylex); cellm2.setCellStyle(stylex); cellm3.setCellStyle(stylex); cellm4.setCellStyle(stylex); cellm5.setCellStyle(stylex); cellm6.setCellStyle(stylex); cellm7.setCellStyle(stylex); cellm8.setCellStyle(stylex); cellm9.setCellStyle(stylex); cellm10.setCellStyle(stylex); cellmk11.setCellStyle(stylex); HSSFRow rw4n = shet3.createRow(0); rw4n.setHeightInPoints(45); rw4n.setRowStyle(style2); // rw4.createCell(1).setCellValue("Number"); HSSFCell cell0n, cell1n, cell2n, cell3n, cell4n, cell5n, cell6n, cell7n, cell8n, cell9n, cell10n, cell11n, cell12n, cell13n, cell14n, cell15n, cell16n, cell17n, cell18n; cell0n = rw4n.createCell(0); cell1n = rw4n.createCell(1); cell2n = rw4n.createCell(2); cell3n = rw4n.createCell(3); cell4n = rw4n.createCell(4); cell5n = rw4n.createCell(5); cell6n = rw4n.createCell(6); cell7n = rw4n.createCell(7); cell8n = rw4n.createCell(8); cell9n = rw4n.createCell(9); cell10n = rw4n.createCell(10); cell11n = rw4n.createCell(11); cell12n = rw4n.createCell(12); cell13n = rw4n.createCell(13); cell14n = rw4n.createCell(14); cell15n = rw4n.createCell(15); cell16n = rw4n.createCell(16); cell17n = rw4n.createCell(17); cell18n = rw4n.createCell(18); cell0n.setCellValue("County name"); cell1n.setCellValue("Partner name"); cell2n.setCellValue("District name"); cell3n.setCellValue("Group name"); cell4n.setCellValue("Service provider"); cell5n.setCellValue("Client name"); cell6n.setCellValue("Age"); cell7n.setCellValue("Gender"); cell8n.setCellValue("Message (s)"); cell9n.setCellValue("Received Contraceptives"); cell10n.setCellValue("Reffered To Service Point"); cell11n.setCellValue("Given Condoms"); cell12n.setCellValue("Screened For TB"); cell13n.setCellValue("Screened For STIs"); cell14n.setCellValue("Partner Tested"); cell15n.setCellValue("Children Tested"); cell16n.setCellValue("Disclosed Status"); cell17n.setCellValue("Submission date"); cell18n.setCellValue("Timestamp"); cell0n.setCellStyle(stylex); cell1n.setCellStyle(stylex); cell2n.setCellStyle(stylex); cell3n.setCellStyle(stylex); cell4n.setCellStyle(stylex); cell5n.setCellStyle(stylex); cell6n.setCellStyle(stylex); cell7n.setCellStyle(stylex); cell8n.setCellStyle(stylex); cell9n.setCellStyle(stylex); cell10n.setCellStyle(stylex); cell11n.setCellStyle(stylex); cell12n.setCellStyle(stylex); cell13n.setCellStyle(stylex); cell14n.setCellStyle(stylex); cell15n.setCellStyle(stylex); cell16n.setCellStyle(stylex); cell17n.setCellStyle(stylex); cell18n.setCellStyle(stylex); pos1 = 1; pos2 = 1; pos3 = 1; //String getClientRegistration="SELECT county.county_name,partner.partner_name,district.district_name,group_id,clients.age,provider_id, " // + "clients.gender,clients.timestamp,clients.fname,clients.mname,clients.lname FROM clients JOIN partner ON clients.partner_id=partner.partner_id " // + "JOIN (district JOIN county ON district.county_id=county.county_id )ON district.district_id=clients.district_id " // + "WHERE STR_TO_DATE(clients.timestamp,'%Y-%m-%d') BETWEEN STR_TO_DATE('"+startdate+"','%Y-%m-%d') AND STR_TO_DATE('"+enddate+"','%Y-%m-%d')"; // conn.rs=conn.st.executeQuery(getClientRegistration); // while(conn.rs.next()){ // countyname=conn.rs.getString(1); // partnername=conn.rs.getString(2); // districtname=conn.rs.getString(3); // age=conn.rs.getInt(5); // gender=conn.rs.getString(7); // timestamp=conn.rs.getString(8); // // clientname=conn.rs.getString(9)+" "+conn.rs.getString(10)+" "+conn.rs.getString(11); // if(conn.rs.getString(10).equals(conn.rs.getString(11))){ // clientname=conn.rs.getString(9)+" "+conn.rs.getString(11); // } // // if(!conn.rs.getString(4).equals("0")){ // String getGroupname="SELECT group_name FROM groups WHERE group_id='"+conn.rs.getString(4)+"'"; // conn.rs1=conn.st1.executeQuery(getGroupname); // if(conn.rs1.next()==true){ // groupname=conn.rs1.getString(1); // } // } // else{ // groupname="INDIVIDUALS"; // } // String getProvider="SELECT fname,mname,lname FROM service_provider WHERE provider_id='"+conn.rs.getString(6)+"'"; // conn.rs1=conn.st1.executeQuery(getProvider); // if(conn.rs1.next()==true){ // providername=conn.rs1.getString(1)+" "+conn.rs1.getString(2)+" "+conn.rs1.getString(3); // if(conn.rs1.getString(2).equals(conn.rs1.getString(3))){ // providername=conn.rs1.getString(1)+" "+conn.rs1.getString(3); // } // } //// ADD TO THE EXCELL OUTPUT.............................................................. // // HSSFRow rw4x=shet1.createRow(pos1); // rw4x.setHeightInPoints(25); // rw4x.setRowStyle(style2); // HSSFCell cell0x,cell1x,cell2x,cell3x,cell4x,cell5x,cell6x,cell7x,cell8x; // cell0x=rw4x.createCell(0); // cell1x=rw4x.createCell(1); // cell2x=rw4x.createCell(2); // cell3x=rw4x.createCell(3); // cell4x=rw4x.createCell(4); // cell5x=rw4x.createCell(5); // cell6x=rw4x.createCell(6); // cell7x=rw4x.createCell(7); // cell8x=rw4x.createCell(8); // // // OUTPUT SERVICES PROVIDED================================ // cell0x .setCellValue(countyname); // cell1x.setCellValue(partnername); // cell2x.setCellValue(districtname); // cell3x.setCellValue(groupname); // cell4x.setCellValue(providername); // cell5x.setCellValue(clientname); // cell6x.setCellValue(age); // cell7x.setCellValue(gender); // cell8x.setCellValue(timestamp); // // cell0x .setCellStyle(stborder); // cell1x.setCellStyle(stborder); // cell2x.setCellStyle(stborder); // cell3x.setCellStyle(stborder); // cell4x.setCellStyle(stborder); // cell5x.setCellStyle(stborder); // cell6x.setCellStyle(stborder); // cell7x.setCellStyle(stborder); // cell8x.setCellStyle(stborder); // // // pos1++; // } // CHECK SESSIONS ATTENDED============================================================== String getSessioner = "SELECT county.county_name,partner.partner_name,district.district_name,group_id,clients.age,provider_id, " + "clients.gender,register2.timestamp,register2.session_no,register2.value,clients.fname,clients.mname,clients.lname,register2.date " + "FROM clients JOIN partner ON clients.partner_id=partner.partner_id " + "JOIN (district JOIN county ON district.county_id=county.county_id )ON district.district_id=clients.district_id " + "JOIN register2 ON register2.client_id=clients.client_id " + "WHERE register2.value<'5' && register2.datekey<'" + datekey + "' && register2.datekey>'0' && STR_TO_DATE(register2.timestamp,'%Y-%m-%d') BETWEEN STR_TO_DATE('" + startdate + "','%Y-%m-%d') AND STR_TO_DATE('" + enddate + "','%Y-%m-%d')" + " ORDER BY clients.client_id "; conn.rs = conn.st.executeQuery(getSessioner); while (conn.rs.next()) { countyname = conn.rs.getString(1); partnername = conn.rs.getString(2); districtname = conn.rs.getString(3); age = conn.rs.getInt(5); gender = conn.rs.getString(7); timestamp = conn.rs.getString(8); sessionno = conn.rs.getInt(9); value = conn.rs.getInt(10); // String sessiondate=conn.rs.getString(14); String[] sessdt = conn.rs.getString(14).split("/"); String sessiondate = sessdt[2] + "-" + sessdt[0] + "-" + sessdt[1]; if (value == 1) { attendance_status = "Present"; } else { attendance_status = "Absent"; } clientname = conn.rs.getString(11) + " " + conn.rs.getString(12) + " " + conn.rs.getString(13); if (conn.rs.getString(12).equals(conn.rs.getString(13))) { clientname = conn.rs.getString(11) + " " + conn.rs.getString(13); } if (!conn.rs.getString(4).equals("0")) { String getGroupname = "SELECT group_name FROM groups WHERE group_id='" + conn.rs.getString(4) + "'"; conn.rs1 = conn.st1.executeQuery(getGroupname); if (conn.rs1.next() == true) { groupname = conn.rs1.getString(1); } } else { groupname = "INDIVIDUALS"; } String getProvider = "SELECT fname,mname,lname FROM service_provider WHERE provider_id='" + conn.rs.getString(6) + "'"; conn.rs1 = conn.st1.executeQuery(getProvider); if (conn.rs1.next() == true) { providername = conn.rs1.getString(1) + " " + conn.rs1.getString(2) + " " + conn.rs1.getString(3); if (conn.rs1.getString(2).equals(conn.rs1.getString(3))) { providername = conn.rs1.getString(1) + " " + conn.rs1.getString(3); } } String getMessage = "SELECT message FROM message_codes WHERE message_id='" + sessionno + "'"; conn.rs1 = conn.st1.executeQuery(getMessage); if (conn.rs1.next()) { messagename = conn.rs1.getString(1); } // ADD TO THE EXCELL OUTPUT.............................................................. HSSFRow rw2m1 = shet2.createRow(pos2); rw2m1.setHeightInPoints(25); rw2m1.setRowStyle(style2); // rw4.createCell(1).setCellValue("Number"); HSSFCell cellm01, cellm11, cellm21, cellm31, cellm41, cellm51, cellm61, cellm71, cellm81, cellm91, cellm101, cellm111; cellm01 = rw2m1.createCell(0); cellm11 = rw2m1.createCell(1); cellm21 = rw2m1.createCell(2); cellm31 = rw2m1.createCell(3); cellm41 = rw2m1.createCell(4); cellm51 = rw2m1.createCell(5); cellm61 = rw2m1.createCell(6); cellm71 = rw2m1.createCell(7); cellm81 = rw2m1.createCell(8); cellm91 = rw2m1.createCell(9); cellm101 = rw2m1.createCell(10); cellm111 = rw2m1.createCell(11); cellm01.setCellValue(countyname); cellm11.setCellValue(partnername); cellm21.setCellValue(districtname); cellm31.setCellValue(groupname); cellm41.setCellValue(providername); cellm51.setCellValue(clientname); cellm61.setCellValue(age); cellm71.setCellValue(gender); cellm81.setCellValue(messagename); cellm91.setCellValue(attendance_status); cellm101.setCellValue(sessiondate); cellm111.setCellValue(timestamp); cellm01.setCellStyle(stborder); cellm11.setCellStyle(stborder); cellm21.setCellStyle(stborder); cellm31.setCellStyle(stborder); cellm41.setCellStyle(stborder); cellm51.setCellStyle(stborder); cellm61.setCellStyle(stborder); cellm71.setCellStyle(stborder); cellm81.setCellStyle(stborder); cellm91.setCellStyle(stborder); cellm101.setCellStyle(stborder); cellm111.setCellStyle(stborder); pos2++; System.out.println("register record number : " + pos2); } System.out.println("finished processing register2"); // CHECK SESSIONS ATTENDED============================================================== String getServices = "SELECT county.county_name,partner.partner_name,district.district_name,group_id,clients.age,provider_id, " + "clients.gender,services_provided.timestamp,services_provided.session_no,services_provided.contraceptive_method," + "services_provided.rsp,services_provided.cds_given,services_provided.screened_tb, services_provided.screened_stis, services_provided.tested_partner, services_provided.tested_children, services_provided.disclosed_status" + ",clients.fname,clients.mname,clients.lname,services_provided.submission_date" + " FROM clients JOIN partner ON clients.partner_id=partner.partner_id " + "JOIN (district JOIN county ON district.county_id=county.county_id )ON district.district_id=clients.district_id " + "JOIN services_provided ON services_provided.client_id=clients.client_id " + "WHERE STR_TO_DATE(services_provided.submission_date,'%m/%d/%Y')< STR_TO_DATE(services_provided.submission_date,'" + submissiondate + "') && STR_TO_DATE(services_provided.timestamp,'%Y-%m-%d') BETWEEN STR_TO_DATE('" + startdate + "','%Y-%m-%d') AND STR_TO_DATE('" + enddate + "','%Y-%m-%d') " // + " && (services_provided.contraceptive_method='YES' || services_provided.rsp || services_provided.cds_given>0 || services_provided.screened_tb='YES' || services_provided.screened_stis='YES' || services_provided.tested_partner='YES' || services_provided.tested_children='YES' || services_provided.disclosed_status='YES')" + " ORDER BY clients.client_id "; conn.rs = conn.st.executeQuery(getServices); while (conn.rs.next()) { cm = rsp = screenedTB = ScreenedStis = screenedTb = testedpartner = testedChildren = discosedStatus = messagename = ""; givenCDS = 0; countyname = conn.rs.getString(1); partnername = conn.rs.getString(2); districtname = conn.rs.getString(3); age = conn.rs.getInt(5); gender = conn.rs.getString(7); timestamp = conn.rs.getString(8); sess = conn.rs.getString(9).split(","); cm = conn.rs.getString(10); rsp = conn.rs.getString(11); givenCDS = conn.rs.getInt(12); screenedTb = conn.rs.getString(13); ScreenedStis = conn.rs.getString(14); testedpartner = conn.rs.getString(15); testedChildren = conn.rs.getString(16); discosedStatus = conn.rs.getString(17); String submissiondate = conn.rs.getString(21); clientname = conn.rs.getString(18) + " " + conn.rs.getString(19) + " " + conn.rs.getString(20); if (conn.rs.getString(19).equals(conn.rs.getString(20))) { clientname = conn.rs.getString(18) + " " + conn.rs.getString(20); } for (String session1 : sess) { if (!(session1.equals("") || session1.equals(","))) { String getMess = "SELECT message FROM message_codes WHERE message_id='" + session1 + "'"; conn.rs1 = conn.st1.executeQuery(getMess); if (conn.rs1.next() == true) { messagename += conn.rs1.getString(1) + "\n"; } } } if (!conn.rs.getString(4).equals("0")) { String getGroupname = "SELECT group_name FROM groups WHERE group_id='" + conn.rs.getString(4) + "'"; conn.rs1 = conn.st1.executeQuery(getGroupname); if (conn.rs1.next() == true) { groupname = conn.rs1.getString(1); } } else { groupname = "INDIVIDUALS"; } String getProvider = "SELECT fname,mname,lname FROM service_provider WHERE provider_id='" + conn.rs.getString(6) + "'"; conn.rs1 = conn.st1.executeQuery(getProvider); if (conn.rs1.next() == true) { providername = conn.rs1.getString(1) + " " + conn.rs1.getString(2) + " " + conn.rs1.getString(3); if (conn.rs1.getString(2).equals(conn.rs1.getString(3))) { providername = conn.rs1.getString(1) + " " + conn.rs1.getString(3); } } // ADD TO THE EXCELL OUTPUT.............................................................. HSSFRow rw4n1 = shet3.createRow(pos3); rw4n1.setHeightInPoints(25); rw4n1.setRowStyle(style2); // rw4.createCell(1).setCellValue("Number"); HSSFCell cell0n1, cell1n1, cell2n1, cell3n1, cell4n1, cell5n1, cell6n1, cell7n1, cell8n1, cell9n1, cell10n1, cell11n1, cell12n1, cell13n1, cell14n1, cell15n1, cell16n1, cell17n1, cell18n1; cell0n1 = rw4n1.createCell(0); cell1n1 = rw4n1.createCell(1); cell2n1 = rw4n1.createCell(2); cell3n1 = rw4n1.createCell(3); cell4n1 = rw4n1.createCell(4); cell5n1 = rw4n1.createCell(5); cell6n1 = rw4n1.createCell(6); cell7n1 = rw4n1.createCell(7); cell8n1 = rw4n1.createCell(8); cell9n1 = rw4n1.createCell(9); cell10n1 = rw4n1.createCell(10); cell11n1 = rw4n1.createCell(11); cell12n1 = rw4n1.createCell(12); cell13n1 = rw4n1.createCell(13); cell14n1 = rw4n1.createCell(14); cell15n1 = rw4n1.createCell(15); cell16n1 = rw4n1.createCell(16); cell17n1 = rw4n1.createCell(17); cell18n1 = rw4n1.createCell(18); cell0n1.setCellValue(countyname); cell1n1.setCellValue(partnername); cell2n1.setCellValue(districtname); cell3n1.setCellValue(groupname); cell4n1.setCellValue(providername); cell5n1.setCellValue(clientname); cell6n1.setCellValue(age); cell7n1.setCellValue(gender); cell8n1.setCellValue(messagename); cell9n1.setCellValue(cm); cell10n1.setCellValue(rsp); cell11n1.setCellValue(givenCDS); cell12n1.setCellValue(screenedTb); cell13n1.setCellValue(ScreenedStis); cell14n1.setCellValue(testedpartner); cell15n1.setCellValue(testedChildren); cell16n1.setCellValue(discosedStatus); cell17n1.setCellValue(submissiondate); cell18n1.setCellValue(timestamp); cell0n1.setCellStyle(stborder); cell1n1.setCellStyle(stborder); cell2n1.setCellStyle(stborder); cell3n1.setCellStyle(stborder); cell4n1.setCellStyle(stborder); cell5n1.setCellStyle(stborder); cell6n1.setCellStyle(stborder); cell7n1.setCellStyle(stborder); cell8n1.setCellStyle(stborder); cell9n1.setCellStyle(stborder); cell10n1.setCellStyle(stborder); cell11n1.setCellStyle(stborder); cell12n1.setCellStyle(stborder); cell13n1.setCellStyle(stborder); cell14n1.setCellStyle(stborder); cell15n1.setCellStyle(stborder); cell16n1.setCellStyle(stborder); cell17n1.setCellStyle(stborder); cell18n1.setCellStyle(stborder); pos3++; System.out.println("services record number : " + pos3); } System.out.println("finished all"); if (conn.rs != null) { conn.rs.close(); } if (conn.st != null) { conn.st.close(); } if (conn.rs1 != null) { conn.rs1.close(); } if (conn.st1 != null) { conn.st1.close(); } if (conn.rs2 != null) { conn.rs2.close(); } if (conn.st2 != null) { conn.st2.close(); } if (conn.st3 != null) { conn.st3.close(); } if (conn.pst != null) { conn.pst.close(); } if (conn.pst != null) { conn.pst.close(); } if (conn.pst1 != null) { conn.pst1.close(); } if (conn.pst1 != null) { conn.pst1.close(); } if (conn.conn != null) { conn.conn.close(); } // write it as an excel attachment ByteArrayOutputStream outByteStream = new ByteArrayOutputStream(); wb.write(outByteStream); byte[] outArray = outByteStream.toByteArray(); response.setContentType("application/ms-excel"); response.setContentLength(outArray.length); response.setHeader("Expires:", "0"); // eliminates browser caching response.setHeader("Content-Disposition", "attachment; filename=PWP_Raw_Data_Between_" + sdate.trim() + "_AND_" + ndate.trim() + ".xls"); OutputStream outStream = response.getOutputStream(); outStream.write(outArray); outStream.flush(); }
From source file:Datim.datimHTCReport.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException { session = request.getSession();/*from w w w . jav a 2s .com*/ dbConn conn = new dbConn(); // MALES double MaleAdultTested; double MaleTestedChild; double AdultMaleHIV; double ChildMaleHIV; double FemaleAdultTested1 = 0.0; double FemaleAdultTested4 = 0.0; double FemaleAdultTested9 = 0.0; double FemaleAdultTested14 = 0.0; double FemaleAdultTested19 = 0.0; double FemaleAdultTested24 = 0.0; double FemaleAdultTested49 = 0.0; double FemaleAdultTested50 = 0.0; double FemaleTestedChild1 = 0.0; double FemaleTestedChild4 = 0.0; double FemaleTestedChild9 = 0.0; double FemaleTestedChild14 = 0.0; double FemaleTestedChild19 = 0.0; double FemaleTestedChild24 = 0.0; double FemaleTestedChild49 = 0.0; double FemaleTestedChild50 = 0.0; double AdultFemaleHIV19Neg = 0.0; double AdultFemaleHIV24Neg = 0.0; double AdultFemaleHIV49Neg = 0.0; double AdultFemaleHIV50Neg = 0.0; double AdultFemaleHIV19 = 0.0; double AdultFemaleHIV24 = 0.0; double AdultFemaleHIV49 = 0.0; double AdultFemaleHIV50 = 0.0; double ChildFemaleHIV1 = 0.0; double ChildFemaleHIV4 = 0.0; double ChildFemaleHIV9 = 0.0; double ChildFemaleHIV14 = 0.0; double ChildFemaleHIV1Neg = 0.0; double ChildFemaleHIV4Neg = 0.0; double ChildFemaleHIV9Neg = 0.0; double ChildFemaleHIV14Neg = 0.0; // MALES double MaleAdultTested19Neg = 0.0; double MaleAdultTested21Neg = 0.0; double MaleAdultTested49Neg = 0.0; double MaleAdultTested50Neg = 0.0; double MaleAdultTested19 = 0.0; double MaleAdultTested24 = 0.0; double MaleAdultTested49 = 0.0; double MaleAdultTested50 = 0.0; double MaleTestedChild1 = 0.0; double MaleTestedChild4 = 0.0; double MaleTestedChild9 = 0.0; double MaleTestedChild14 = 0.0; double MaleTestedChild1Neg = 0.0; double MaleTestedChild4Neg = 0.0; double MaleTestedChild9Neg = 0.0; double MaleTestedChild14Neg = 0.0; double AdultMaleHIV19Neg = 0.0; double AdultMaleHIV24Neg = 0.0; double AdultMaleHIV49Neg = 0.0; double AdultMaleHIV50Neg = 0.0; double AdultMaleHIV19 = 0.0; double AdultMaleHIV24 = 0.0; double AdultMaleHIV49 = 0.0; double AdultMaleHIV50 = 0.0; double ChildMaleHIV1 = 0.0; double ChildMaleHIV4 = 0.0; double ChildMaleHIV9 = 0.0; double ChildMaleHIV14 = 0.0; double ChildMaleHIV1Neg = 0.0; double ChildMaleHIV4Neg = 0.0; double ChildMaleHIV9Neg = 0.0; double ChildMaleHIV14Neg = 0.0; year = Integer.parseInt(request.getParameter("year")); reportDuration = request.getParameter("reportDuration"); // year=2015; // reportDuration="4"; period = ""; prevYear = year - 1; maxYearMonth = 0; FemaleAdultTested = 0.0; FemaleTestedChild = 0.0; AdultFemaleHIV = 0.0; ChildFemaleHIV = 0.0; double TotalTested = 0.0; double TotalPositiveFemale = 0.0; double TotalPositiveMale = 0.0; double TotalNegativeFemale = 0.0; double TotalNegativeMale = 0.0; // MALES MaleAdultTested = 0.0; MaleTestedChild = 0.0; AdultMaleHIV = 0.0; ChildMaleHIV = 0.0; double TotalPositive = 0.0; double TotalNegative = 0.0; String county = ""; String district = ""; String facilityname = ""; // GET REPORT DURATION============================================ if (reportDuration.equals("1")) { duration = " moh711.yearmonth BETWEEN " + prevYear + "10 AND " + year + "09"; period = "DATIM ANNUAL DATA REPORT FOR PEPFAR YEAR : " + year; } else if (reportDuration.equals("2")) { semi_annual = request.getParameter("semi_annual"); // semi_annual="2"; if (semi_annual.equals("1")) { duration = " moh711.yearmonth BETWEEN " + prevYear + "10 AND " + year + "03"; period = "DATIM SEMI - ANNUAL DATA REPORT FOR PERIOD : OCT " + prevYear + " to MARCH " + year; } else { duration = " moh711.yearmonth BETWEEN " + year + "04 AND " + year + "09"; period = "DATIM SEMI - ANNUAL DATA REPORT FOR PERIOD : APRIL " + year + " to SEPT " + year; } } else if (reportDuration.equals("3")) { String startMonth, endMonth; quarter = request.getParameter("quarter"); // quarter="3"; String getMonths = "SELECT months,name FROM quarter WHERE id='" + quarter + "'"; conn.rs = conn.st.executeQuery(getMonths); if (conn.rs.next() == true) { String months[] = conn.rs.getString(1).split(","); startMonth = months[0]; endMonth = months[2]; if (quarter.equals("1")) { duration = " moh711.yearmonth BETWEEN " + prevYear + "" + startMonth + " AND " + prevYear + "" + endMonth; period = "DATIM QUARTERLY DATA REPORT FOR PERIOD : " + conn.rs.getString(2).replace("-", " " + prevYear + " TO ") + " " + prevYear + ""; } else { duration = " moh711.yearmonth BETWEEN " + year + "" + startMonth + " AND " + year + "" + endMonth; period = "DATIM QUARTERLY DATA REPORT FOR PERIOD : " + conn.rs.getString(2).replace("-", " " + year + " TO ") + " " + year + ""; } } } else if (reportDuration.equals("4")) { month = Integer.parseInt(request.getParameter("month")); // month=5; String getMonthName = "SELECT name FROM month WHERE id='" + month + "'"; conn.rs = conn.st.executeQuery(getMonthName); if (conn.rs.next() == true) { if (month >= 10) { duration = " moh711.yearmonth=" + prevYear + "" + month; period = "DATIM MONTHLY DATA REPORT FOR : " + conn.rs.getString(1) + "(" + prevYear + ")"; } else { duration = " moh711.yearmonth=" + year + "0" + month; period = "DATIM MONTHLY DATA REPORT FOR : " + conn.rs.getString(1) + "(" + year + ")"; } } } else { duration = ""; } System.out.println("period is : " + period); // GET FACILITIES TO OUTPUT................................. mflcode = countyName = districtName = facilityName = ""; // facilityId=request.getParameter("facility"); facilityId = "403"; HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet shet3 = wb.createSheet("DATIM DATA FROM MOH 711 "); HSSFFont font = wb.createFont(); font.setFontHeightInPoints((short) 18); font.setFontName("Arial Black"); font.setColor((short) 0000); CellStyle style = wb.createCellStyle(); style.setFont(font); style.setAlignment(HSSFCellStyle.ALIGN_LEFT); HSSFFont font2 = wb.createFont(); font2.setFontName("Arial Black"); font2.setColor((short) 0000); CellStyle style2 = wb.createCellStyle(); style2.setFont(font2); HSSFCellStyle stborder = wb.createCellStyle(); stborder.setBorderTop(HSSFCellStyle.BORDER_THIN); stborder.setBorderBottom(HSSFCellStyle.BORDER_THIN); stborder.setBorderLeft(HSSFCellStyle.BORDER_THIN); stborder.setBorderRight(HSSFCellStyle.BORDER_THIN); stborder.setAlignment(HSSFCellStyle.ALIGN_LEFT); stborder.setWrapText(true); HSSFCellStyle stylex = wb.createCellStyle(); stylex.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index); stylex.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); stylex.setBorderTop(HSSFCellStyle.BORDER_THIN); stylex.setBorderBottom(HSSFCellStyle.BORDER_THIN); stylex.setBorderLeft(HSSFCellStyle.BORDER_THIN); stylex.setBorderRight(HSSFCellStyle.BORDER_THIN); stylex.setAlignment(HSSFCellStyle.ALIGN_LEFT); HSSFFont fontx = wb.createFont(); fontx.setColor(HSSFColor.DARK_BLUE.index); stylex.setFont(fontx); stylex.setWrapText(true); HSSFCellStyle stylemainHeader = wb.createCellStyle(); stylemainHeader.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index); stylemainHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); stylemainHeader.setBorderTop(HSSFCellStyle.BORDER_THIN); stylemainHeader.setBorderBottom(HSSFCellStyle.BORDER_THIN); stylemainHeader.setBorderLeft(HSSFCellStyle.BORDER_THIN); stylemainHeader.setBorderRight(HSSFCellStyle.BORDER_THIN); stylemainHeader.setAlignment(HSSFCellStyle.ALIGN_LEFT); stylemainHeader.setWrapText(true); HSSFCellStyle styleHeader = wb.createCellStyle(); styleHeader.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index); styleHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); styleHeader.setBorderTop(HSSFCellStyle.BORDER_THIN); styleHeader.setBorderBottom(HSSFCellStyle.BORDER_THIN); styleHeader.setBorderLeft(HSSFCellStyle.BORDER_THIN); styleHeader.setBorderRight(HSSFCellStyle.BORDER_THIN); styleHeader.setAlignment(HSSFCellStyle.ALIGN_LEFT); styleHeader.setWrapText(true); HSSFCellStyle styleminiHeader = wb.createCellStyle(); styleminiHeader.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); styleminiHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); styleminiHeader.setBorderTop(HSSFCellStyle.BORDER_THIN); styleminiHeader.setBorderBottom(HSSFCellStyle.BORDER_THIN); styleminiHeader.setBorderLeft(HSSFCellStyle.BORDER_THIN); styleminiHeader.setBorderRight(HSSFCellStyle.BORDER_THIN); styleminiHeader.setAlignment(HSSFCellStyle.ALIGN_LEFT); styleminiHeader.setWrapText(true); HSSFFont fontHeader = wb.createFont(); fontHeader.setColor(HSSFColor.DARK_BLUE.index); styleHeader.setFont(fontHeader); styleHeader.setWrapText(true); shet3.setColumnWidth(0, 4000); for (int i = 1; i <= 17; i++) { shet3.setColumnWidth(i, 2000); } HSSFRow rw0 = shet3.createRow(0); rw0.setHeightInPoints(25); HSSFCell c1, c2, c3, c4, c5, c6, c7, c8; c1 = rw0.createCell(0); c1.setCellValue(period); c1.setCellStyle(stylemainHeader); for (int j = 1; j <= 17; j++) { c1 = rw0.createCell(j); c1.setCellStyle(stylemainHeader); } shet3.addMergedRegion(new CellRangeAddress(0, 0, 0, 17)); Calendar ca = Calendar.getInstance(); int currentyear = ca.get(Calendar.YEAR); String facilitiestable = "subpartnera"; int selectedyear = year; if (selectedyear < currentyear) { if (year < 2014) { //db for 2014 is the smallest facilitiestable = "subpartnera2014"; } else { facilitiestable = "subpartnera" + selectedyear; } } String getName = "SELECT " + facilitiestable + ".SubPartnerNom,district.DistrictNom,county.County," + facilitiestable + ".CentreSanteId FROM " + facilitiestable + " " + "JOIN district ON " + facilitiestable + ".DistrictID=district.DistrictID JOIN county ON " + "district.CountyID=county.CountyID WHERE " + facilitiestable + ".SubPartnerID='" + facilityId + "'"; conn.rs = conn.st.executeQuery(getName); if (conn.rs.next() == true) { facilityName = conn.rs.getString(1); districtName = conn.rs.getString(2); countyName = conn.rs.getString(3); mflcode = conn.rs.getString(4); } String getMaxYearMonth = "SELECT MAX(yearmonth) FROM moh711 WHERE moh711.SubPartnerID='" + facilityId + "' && " + duration; conn.rs = conn.st.executeQuery(getMaxYearMonth); if (conn.rs.next() == true) { maxYearMonth = conn.rs.getInt(1); } // for header--------------------------------------------------------------------------- HSSFCell c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c110, c111, c112, c113, c114, c115, c116, c117, c118, c119, c120, c121, c122, c123, c124, c125, c126, c127, c128, c129, c130, c131, c132, c133, c134, c135, c136; HSSFCell c211, c212, c213, c214, c215, c216, c217; rw0 = shet3.createRow(2); rw0.setHeightInPoints(20); rw0.setHeightInPoints(20); c211 = rw0.createCell(0); c212 = rw0.createCell(1); c213 = rw0.createCell(2); c214 = rw0.createCell(3); c215 = rw0.createCell(4); c216 = rw0.createCell(5); c217 = rw0.createCell(6); c211.setCellValue("COUNTY"); c212.setCellValue("SUB-COUNTY"); c213.setCellValue("FACILITY"); c214.setCellValue("MFL-CODE"); c215.setCellValue("TYPE OF SUPPORT"); c11 = rw0.createCell(7); c12 = rw0.createCell(8); c13 = rw0.createCell(9); c14 = rw0.createCell(10); c15 = rw0.createCell(11); c16 = rw0.createCell(12); c17 = rw0.createCell(13); c18 = rw0.createCell(14); c19 = rw0.createCell(15); c110 = rw0.createCell(16); c111 = rw0.createCell(17); c112 = rw0.createCell(18); c113 = rw0.createCell(19); c114 = rw0.createCell(20); c115 = rw0.createCell(21); c116 = rw0.createCell(22); c117 = rw0.createCell(23); c118 = rw0.createCell(24); c119 = rw0.createCell(25); c120 = rw0.createCell(26); c121 = rw0.createCell(27); c122 = rw0.createCell(28); c123 = rw0.createCell(29); c124 = rw0.createCell(30); c125 = rw0.createCell(31); c126 = rw0.createCell(32); c127 = rw0.createCell(33); c128 = rw0.createCell(34); c129 = rw0.createCell(35); c130 = rw0.createCell(36); c131 = rw0.createCell(37); c132 = rw0.createCell(38); c133 = rw0.createCell(39); c134 = rw0.createCell(40); c135 = rw0.createCell(41); c136 = rw0.createCell(42); c216.setCellValue("Total HIV+"); c217.setCellValue("Total HIV+ (F)"); c11.setCellValue("POSITIVE"); c12.setCellValue("FEMALE"); c13.setCellValue(""); c14.setCellValue(""); c15.setCellValue(""); c16.setCellValue(""); c17.setCellValue(""); c18.setCellValue(""); c19.setCellValue(""); c110.setCellValue(""); c111.setCellValue("MALE"); c112.setCellValue(""); c113.setCellValue(""); c114.setCellValue(""); c115.setCellValue(""); c116.setCellValue(""); c117.setCellValue(""); c118.setCellValue(""); // // rw0=shet3.createRow(2); // rw0.setHeightInPoints(20); c119.setCellValue("NEGATIVE"); c120.setCellValue("FEMALE"); c121.setCellValue(""); c122.setCellValue(""); c123.setCellValue(""); c124.setCellValue(""); c125.setCellValue(""); c126.setCellValue(""); c127.setCellValue(""); c128.setCellValue(""); c129.setCellValue("MALE"); c130.setCellValue(""); c131.setCellValue(""); c132.setCellValue(""); c133.setCellValue(""); c134.setCellValue(""); c135.setCellValue(""); c136.setCellValue(""); for (int i = 0; i <= 22; i++) { c11 = rw0.getCell(i); c11.setCellStyle(stylemainHeader); } for (int i = 23; i <= 42; i++) { c11 = rw0.getCell(i); c11.setCellStyle(stylemainHeader); } shet3.addMergedRegion(new CellRangeAddress(2, 2, 8, 15)); shet3.addMergedRegion(new CellRangeAddress(2, 2, 17, 24)); shet3.addMergedRegion(new CellRangeAddress(2, 2, 26, 33)); shet3.addMergedRegion(new CellRangeAddress(2, 2, 35, 42)); rw0 = shet3.createRow(3); rw0.setHeightInPoints(20); c211 = rw0.createCell(0); c212 = rw0.createCell(1); c213 = rw0.createCell(2); c214 = rw0.createCell(3); c215 = rw0.createCell(4); c216 = rw0.createCell(5); c217 = rw0.createCell(6); // other data c11 = rw0.createCell(7); c12 = rw0.createCell(8); c13 = rw0.createCell(9); c14 = rw0.createCell(10); c15 = rw0.createCell(11); c16 = rw0.createCell(12); c17 = rw0.createCell(13); c18 = rw0.createCell(14); c19 = rw0.createCell(15); c110 = rw0.createCell(16); c111 = rw0.createCell(17); c112 = rw0.createCell(18); c113 = rw0.createCell(19); c114 = rw0.createCell(20); c115 = rw0.createCell(21); c116 = rw0.createCell(22); c117 = rw0.createCell(23); c118 = rw0.createCell(24); c11.setCellValue("Num"); c216.setCellValue("TOTAL HIV+"); c217.setCellValue("TOTAL +VE (F)"); c12.setCellValue("Paeds <15Yr"); c13.setCellValue(""); c14.setCellValue(""); c15.setCellValue(""); c16.setCellValue("Adults 15+Yr"); c17.setCellValue(""); c18.setCellValue(""); c19.setCellValue(""); c110.setCellValue("TOTAL +VE MALE"); c111.setCellValue("Paeds <15Yr"); c112.setCellValue(""); c113.setCellValue(""); c114.setCellValue(""); c115.setCellValue("Adults 15+Yr"); c116.setCellValue(""); c117.setCellValue(""); c118.setCellValue(""); c11 = rw0.createCell(25); c12 = rw0.createCell(26); c13 = rw0.createCell(27); c14 = rw0.createCell(28); c15 = rw0.createCell(29); c16 = rw0.createCell(30); c17 = rw0.createCell(31); c18 = rw0.createCell(32); c19 = rw0.createCell(33); c110 = rw0.createCell(34); c111 = rw0.createCell(35); c112 = rw0.createCell(36); c113 = rw0.createCell(37); c114 = rw0.createCell(38); c115 = rw0.createCell(39); c116 = rw0.createCell(40); c117 = rw0.createCell(41); c118 = rw0.createCell(42); c11.setCellValue("TOTAL -VE(F)"); c12.setCellValue("Paeds <15Yr"); c13.setCellValue(""); c14.setCellValue(""); c15.setCellValue(""); c16.setCellValue("Adults 15+Yr"); c17.setCellValue(""); c18.setCellValue(""); c19.setCellValue(""); c110.setCellValue("TOTAL -VE(M)"); c111.setCellValue("Paeds <15Yr"); c112.setCellValue(""); c113.setCellValue(""); c114.setCellValue(""); c115.setCellValue("Adults 15+Yr"); c116.setCellValue(""); c117.setCellValue(""); c118.setCellValue(""); for (int i = 0; i <= 22; i++) { c11 = rw0.getCell(i); c11.setCellStyle(styleHeader); } shet3.addMergedRegion(new CellRangeAddress(3, 3, 8, 11)); shet3.addMergedRegion(new CellRangeAddress(3, 3, 12, 15)); shet3.addMergedRegion(new CellRangeAddress(3, 3, 17, 20)); shet3.addMergedRegion(new CellRangeAddress(3, 3, 21, 24)); // for (int k = 23; k <= 40; k++) { c113 = rw0.getCell(k); c113.setCellStyle(styleHeader); } shet3.addMergedRegion(new CellRangeAddress(3, 3, 26, 29)); shet3.addMergedRegion(new CellRangeAddress(3, 3, 30, 33)); shet3.addMergedRegion(new CellRangeAddress(3, 3, 35, 38)); shet3.addMergedRegion(new CellRangeAddress(3, 3, 39, 42)); rw0 = shet3.createRow(4); rw0.setHeightInPoints(20); c211 = rw0.createCell(0); c212 = rw0.createCell(1); c213 = rw0.createCell(2); c214 = rw0.createCell(3); c215 = rw0.createCell(4); c216 = rw0.createCell(5); c217 = rw0.createCell(6); // for ther est c11 = rw0.createCell(7); c12 = rw0.createCell(8); c13 = rw0.createCell(9); c14 = rw0.createCell(10); c15 = rw0.createCell(11); c16 = rw0.createCell(12); c17 = rw0.createCell(13); c18 = rw0.createCell(14); c19 = rw0.createCell(15); c110 = rw0.createCell(16); c111 = rw0.createCell(17); c112 = rw0.createCell(18); c113 = rw0.createCell(19); c114 = rw0.createCell(20); c115 = rw0.createCell(21); c116 = rw0.createCell(22); c117 = rw0.createCell(23); c118 = rw0.createCell(24); c11.setCellValue("NUM"); c216.setCellValue("TOTAL HIV+"); c217.setCellValue("TOTAL +VE(F)"); c12.setCellValue("<1 "); c13.setCellValue("1-4Y"); c14.setCellValue("5-9Y"); c15.setCellValue("10-14Y"); c16.setCellValue("15-19Y"); c17.setCellValue("20-24Y"); c18.setCellValue("25-49Y"); c19.setCellValue("50+Y"); c110.setCellValue("TOTAL +VE MALE"); shet3.addMergedRegion(new CellRangeAddress(3, 4, 16, 16)); c111.setCellValue("<1"); c112.setCellValue("1-4Y"); c113.setCellValue("5-9Y"); c114.setCellValue("10-14Y"); c115.setCellValue("15-19Y"); c116.setCellValue("20-24Y"); c117.setCellValue("25-49Y"); c118.setCellValue("50+Y"); for (int i = 0; i <= 22; i++) { c11 = rw0.getCell(i); c11.setCellStyle(styleHeader); } // // for negative c11 = rw0.createCell(25); c12 = rw0.createCell(26); c13 = rw0.createCell(27); c14 = rw0.createCell(28); c15 = rw0.createCell(29); c16 = rw0.createCell(30); c17 = rw0.createCell(31); c18 = rw0.createCell(32); c19 = rw0.createCell(33); c110 = rw0.createCell(34); c111 = rw0.createCell(35); c112 = rw0.createCell(36); c113 = rw0.createCell(37); c114 = rw0.createCell(38); c115 = rw0.createCell(39); c116 = rw0.createCell(40); c117 = rw0.createCell(41); c118 = rw0.createCell(42); c11.setCellValue("TOTAL -VE(F)"); shet3.addMergedRegion(new CellRangeAddress(3, 4, 25, 25)); c12.setCellValue("<1"); c13.setCellValue("1-4Y"); c14.setCellValue("5-9Y"); c15.setCellValue("10-14Y"); c16.setCellValue("15-19Y"); c17.setCellValue("20-24Y"); c18.setCellValue("25-49Y"); c19.setCellValue("50+Y"); c110.setCellValue("TOTAL -VE(M)"); shet3.addMergedRegion(new CellRangeAddress(3, 4, 34, 34)); c111.setCellValue("<1"); c112.setCellValue("1-4Y"); c113.setCellValue("5-9Y"); c114.setCellValue("10-14Y"); c115.setCellValue("15-19Y"); c116.setCellValue("20-24Y"); c117.setCellValue("25-49Y"); c118.setCellValue("50+Y"); for (int l = 20; l <= 42; l++) { c113 = rw0.getCell(l); c113.setCellStyle(styleHeader); } int count = 4; TestedAdultMale = TestedAdultFemale = 0; TestedChildMale = TestedChildFemale = 0; HIV_AdultMale = HIV_AdultFemale = 0; HIV_ChildMale = HIV_ChildFemale = 0; //--------------------------------------------------------------------------- String facilid = ""; String facilname = ""; String dsdta = ""; String getfacils = "select SubPartnerId,SubPartnerNom from " + facilitiestable + " where HTC='1' order by SubPartnerNom "; conn.rs2 = conn.st2.executeQuery(getfacils); while (conn.rs2.next()) { facilname = conn.rs2.getString(2); facilid = conn.rs2.getString(1); String getData = "SELECT (sum(VCTClient_Tested_CF) +sum( VCTClient_Tested_AF)+sum(DTCB_Test_Out_AF)+sum(DTCB_Test_In_AF))" //ADULTS TESTED FEMALE + ",(sum(VCTClient_Tested_CM)+ sum(VCTClient_Tested_AM) + sum(DTCB_Test_Out_AM) + sum(DTCB_Test_In_AM))"//ADULTS TESTED MALES + ", (sum(VCTClient_HIV_CF)+ sum(VCTClient_HIV_AF)+sum(DTCC_HIV_In_AF)+ sum(DTCC_HIV_Out_AF))" // ADULTS HIV+ FEMALE + ",(sum(VCTClient_HIV_CM)+sum(VCTClient_HIV_AM)+ sum(DTCC_HIV_In_AM) +sum(DTCC_HIV_Out_AM)) " // ADULTS HIV+ MALE + ", (sum(DTCB_Test_Out_CF) +sum(DTCB_Test_In_CF))" // CHILDREN TOTAL TESTED FEMALE + ", (sum(DTCB_Test_Out_CM) +sum(DTCB_Test_In_CM))" // CHILDREN TOTAL TESTED MALE + ", ( sum(DTCC_HIV_In_CF)+ sum(DTCC_HIV_Out_CF))" // CHILDREN OSITIVE FEMALE + ", (sum(DTCC_HIV_In_CM)+ sum(DTCC_HIV_Out_CM)),county.County,district.DistrictNom," + facilitiestable + ".SubPartnerNom," + facilitiestable + ".CentreSanteId," + facilitiestable + ".HTC_Support1"// CHILDREN POSITIVE MALE + " from moh711 JOIN " + facilitiestable + " ON moh711.SubPartnerID=" + facilitiestable + ".SubPartnerID " + "JOIN district ON " + facilitiestable + ".DistrictID=district.DistrictID " + "JOIN county ON county.CountyID=district.CountyID " + " WHERE " + duration + " and moh711.SubPartnerID='" + facilid + "' "; System.out.println("new : " + getData); conn.rs = conn.st.executeQuery(getData); if (conn.rs.next() == true) { county = conn.rs.getString(9); district = conn.rs.getString(10); facilityname = conn.rs.getString(11); mflcode = conn.rs.getString(12); dsdta = conn.rs.getString(13); TestedAdultFemale = conn.rs.getInt(1); TestedAdultMale = conn.rs.getInt(2); HIV_AdultFemale = conn.rs.getInt(3); HIV_AdultMale = conn.rs.getInt(4); TestedChildFemale = conn.rs.getInt(5); TestedChildMale = conn.rs.getInt(6); HIV_ChildFemale = conn.rs.getInt(7); HIV_ChildMale = conn.rs.getInt(8); String basicDetails = county + "@" + district + "@" + facilityname + "@" + mflcode + "@" + dsdta; String arrayDetails[] = basicDetails.split("@"); count++; rw0 = shet3.createRow(count); int facilno = 0; for (int j = 0; j < arrayDetails.length; j++) { HSSFCell S3cell = rw0.createCell(facilno); S3cell.setCellValue(arrayDetails[j]); // System.out.println(arrayDetails[j]); S3cell.setCellStyle(stborder); System.out.println("facildet pos : " + facilno + " det : " + arrayDetails[j]); facilno++; } System.out.println(facilityname + " TestedAdultFemale " + TestedAdultFemale + "TestedAdultMale " + TestedAdultMale + " TestedChildFemale " + TestedChildFemale + " TestedChildMale " + TestedChildMale + " HIV_AdultFemale " + HIV_AdultFemale + " HIV_AdultMale " + HIV_AdultMale + " HIV_ChildFemale " + HIV_ChildFemale + " HIV_ChildMale " + HIV_ChildMale); // FEMALES FemaleAdultTested19 = (float) Math.round((0.05 * TestedAdultFemale)); FemaleAdultTested24 = (float) Math.round((0.11 * TestedAdultFemale)); FemaleAdultTested49 = (float) Math.round((0.72 * TestedAdultFemale)); FemaleAdultTested50 = (float) Math.round((0.12 * TestedAdultFemale)); FemaleTestedChild1 = (float) Math.round((0.05 * TestedChildFemale)); FemaleTestedChild4 = (float) Math.round((0.26 * TestedChildFemale)); FemaleTestedChild9 = (float) Math.round((0.29 * TestedChildFemale)); FemaleTestedChild14 = (float) Math.round((0.40 * TestedChildFemale)); //postive AdultFemaleHIV19 = (float) Math.round((0.02 * HIV_AdultFemale)); AdultFemaleHIV24 = (float) Math.round((0.09 * HIV_AdultFemale)); AdultFemaleHIV49 = (float) Math.round((0.79 * HIV_AdultFemale)); AdultFemaleHIV50 = (float) Math.round((0.10 * HIV_AdultFemale)); //positve ChildFemaleHIV1 = (float) Math.round((0.13 * HIV_ChildFemale)); ChildFemaleHIV4 = (float) Math.round((0.37 * HIV_ChildFemale)); ChildFemaleHIV9 = (float) Math.round((0.25 * HIV_ChildFemale)); ChildFemaleHIV14 = (float) Math.round((0.25 * HIV_ChildFemale)); // MALES MaleAdultTested19 = (float) Math.round((0.05 * TestedAdultMale)); MaleAdultTested24 = (float) Math.round((0.11 * TestedAdultMale)); MaleAdultTested49 = (float) Math.round((0.72 * TestedAdultMale)); MaleAdultTested50 = (float) Math.round((0.12 * TestedAdultMale)); MaleTestedChild1 = (float) Math.round((0.05 * TestedChildMale)); MaleTestedChild4 = (float) Math.round((0.26 * TestedChildMale)); MaleTestedChild9 = (float) Math.round((0.29 * TestedChildMale)); MaleTestedChild14 = (float) Math.round((0.40 * TestedChildMale)); //positive AdultMaleHIV19 = (float) Math.round((0.02 * HIV_AdultMale)); AdultMaleHIV24 = (float) Math.round((0.09 * HIV_AdultMale)); AdultMaleHIV49 = (float) Math.round((0.79 * HIV_AdultMale)); AdultMaleHIV50 = (float) Math.round((0.10 * HIV_AdultMale)); //positives ChildMaleHIV1 = (float) Math.round((0.13 * HIV_ChildMale)); ChildMaleHIV4 = (float) Math.round((0.37 * HIV_ChildMale)); ChildMaleHIV9 = (float) Math.round((0.25 * HIV_ChildMale)); ChildMaleHIV14 = (float) Math.round((0.25 * HIV_ChildMale)); double splitData; int adderPos = 0; double childSplitData; // TestedAdultFemale=conn.rs.getInt(1); // TestedAdultMale=conn.rs.getInt(2); // HIV_AdultFemale=conn.rs.getInt(3); // HIV_AdultMale=conn.rs.getInt(4); // TestedChildFemale=conn.rs.getInt(5); // TestedChildMale=conn.rs.getInt(6); // HIV_ChildFemale=conn.rs.getInt(7); // HIV_ChildMale=conn.rs.getInt(8); // TotalTested=FemaleTestedChild1+FemaleTestedChild4+FemaleTestedChild9+FemaleTestedChild14+FemaleAdultTested19+FemaleAdultTested24+FemaleAdultTested49+FemaleAdultTested50+ MaleAdultTested19+MaleAdultTested24+MaleAdultTested49+MaleAdultTested50+MaleTestedChild1+MaleTestedChild4+MaleTestedChild9+MaleTestedChild14; // TotalPositiveFemale=AdultFemaleHIV19+AdultFemaleHIV24+AdultFemaleHIV49+AdultFemaleHIV50+ChildFemaleHIV1+ChildFemaleHIV4+ChildFemaleHIV9+ChildFemaleHIV14 ; // TotalPositiveMale1=AdultMaleHIV19+AdultMaleHIV24+AdultMaleHIV49+AdultMaleHIV50+ChildMaleHIV1+ChildMaleHIV4+ChildMaleHIV9+ChildMaleHIV14; // TotalNegativeFemale1=AdultFemaleHIV19Neg+AdultFemaleHIV24Neg+AdultFemaleHIV49Neg+AdultFemaleHIV50Neg+ ChildFemaleHIV1Neg+ChildFemaleHIV4Neg+ChildFemaleHIV9Neg+ChildFemaleHIV14Neg; // TotalNegativeMale1=AdultMaleHIV19Neg+AdultMaleHIV24Neg+AdultMaleHIV49Neg+AdultMaleHIV50Neg+ChildMaleHIV1Neg+ChildMaleHIV4Neg+ChildMaleHIV9Neg+ChildMaleHIV14Neg; adderPos = 0; double Totalhivfemale = 0.0; double Totalhivmale = 0.0; Totalhivfemale = HIV_AdultFemale + HIV_ChildFemale; Totalhivmale = HIV_AdultMale + HIV_ChildMale; // adult female hiv+ splitData = AdultFemaleHIV19 + AdultFemaleHIV24 + AdultFemaleHIV49 + AdultFemaleHIV50; adderPos = 0; while (splitData < HIV_AdultFemale) { AdultFemaleHIV49 += 1; splitData++; } splitData = AdultFemaleHIV19 + AdultFemaleHIV24 + AdultFemaleHIV49 + AdultFemaleHIV50; while (splitData > HIV_AdultFemale) { AdultFemaleHIV49 -= 1; splitData--; } //tested female adults splitData = FemaleAdultTested19 + FemaleAdultTested24 + FemaleAdultTested49 + FemaleAdultTested50; adderPos = 0; while (splitData < TestedAdultFemale) { FemaleAdultTested49 += 1; splitData++; } splitData = FemaleAdultTested19 + FemaleAdultTested24 + FemaleAdultTested49 + FemaleAdultTested50; adderPos = 0; while (splitData > TestedAdultFemale) { FemaleAdultTested49 -= 1; splitData--; } // adult male hiv+ splitData = AdultMaleHIV19 + AdultMaleHIV24 + AdultMaleHIV49 + AdultMaleHIV50; adderPos = 0; while (splitData < HIV_AdultMale) { AdultMaleHIV49 += 1; splitData++; } splitData = AdultMaleHIV19 + AdultMaleHIV24 + AdultMaleHIV49 + AdultMaleHIV50; adderPos = 0; while (splitData > HIV_AdultMale) { AdultMaleHIV49 -= 1; splitData--; } //tested male adults splitData = MaleAdultTested19 + MaleAdultTested24 + MaleAdultTested49 + MaleAdultTested50; adderPos = 0; while (splitData < TestedAdultMale) { MaleAdultTested49 += 1; splitData++; } splitData = MaleAdultTested19 + MaleAdultTested24 + MaleAdultTested49 + MaleAdultTested50; adderPos = 0; while (splitData > TestedAdultMale) { MaleAdultTested49 -= 1; splitData--; } // for child female childSplitData = ChildFemaleHIV1 + ChildFemaleHIV4 + ChildFemaleHIV9 + ChildFemaleHIV14; adderPos = 0; while (childSplitData < HIV_ChildFemale) { if (adderPos < 2) { ChildFemaleHIV4 += 1; } else { ChildFemaleHIV9 += 1; } childSplitData++; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == HIV_ChildFemale) { } } childSplitData = ChildFemaleHIV1 + ChildFemaleHIV4 + ChildFemaleHIV9 + ChildFemaleHIV14; adderPos = 0; while (childSplitData > HIV_ChildFemale) { if (adderPos < 2) { AdultFemaleHIV49 -= 1; } else { AdultFemaleHIV24 -= 1; } childSplitData--; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == HIV_ChildFemale) { } } // for child female tested childSplitData = FemaleTestedChild1 + FemaleTestedChild4 + FemaleTestedChild9 + FemaleTestedChild14; adderPos = 0; while (childSplitData < TestedChildFemale) { if (adderPos < 2) { FemaleTestedChild14 += 1; } else { FemaleTestedChild9 += 1; } childSplitData++; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == TestedChildFemale) { } } childSplitData = FemaleTestedChild1 + FemaleTestedChild4 + FemaleTestedChild9 + FemaleTestedChild14; adderPos = 0; while (childSplitData > TestedChildFemale) { if (adderPos < 2) { FemaleTestedChild14 -= 1; } else { FemaleTestedChild9 -= 1; } childSplitData--; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == TestedChildFemale) { } } // for child male hiv childSplitData = ChildMaleHIV1 + ChildMaleHIV4 + ChildMaleHIV9 + ChildMaleHIV14; adderPos = 0; while (childSplitData < HIV_ChildMale) { if (adderPos < 2) { ChildMaleHIV4 += 1; } else { ChildMaleHIV9 += 1; } childSplitData++; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == HIV_ChildMale) { } } childSplitData = ChildMaleHIV1 + ChildMaleHIV4 + ChildMaleHIV9 + ChildMaleHIV14; adderPos = 0; while (childSplitData > HIV_ChildMale) { if (adderPos < 2) { AdultMaleHIV49 -= 1; } else { AdultMaleHIV24 -= 1; } childSplitData--; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == HIV_ChildMale) { } } /// // for child female tested childSplitData = MaleTestedChild1 + MaleTestedChild4 + MaleTestedChild9 + MaleTestedChild14; adderPos = 0; while (childSplitData < TestedChildMale) { if (adderPos < 2) { MaleTestedChild14 += 1; } else { MaleTestedChild9 += 1; } childSplitData++; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == TestedChildMale) { } } childSplitData = MaleTestedChild1 + MaleTestedChild4 + MaleTestedChild9 + MaleTestedChild14; adderPos = 0; while (childSplitData > TestedChildMale) { if (adderPos < 2) { MaleTestedChild14 -= 1; } else { MaleTestedChild9 -= 1; } childSplitData--; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == TestedChildMale) { } } System.out.println("Neg nn " + ChildMaleHIV1Neg + " " + ChildMaleHIV4Neg + " " + ChildMaleHIV9Neg + " " + ChildMaleHIV14Neg); System.out.println("tested nn " + MaleTestedChild1 + " " + MaleTestedChild4 + " " + MaleTestedChild9 + " " + MaleTestedChild14); System.out.println("hiv+ nnn " + ChildMaleHIV1 + " " + ChildMaleHIV4 + " " + ChildMaleHIV9 + " " + ChildMaleHIV14); // all positives TotalPositive = AdultFemaleHIV19 + AdultFemaleHIV24 + AdultFemaleHIV49 + AdultFemaleHIV50 + AdultMaleHIV19 + AdultMaleHIV24 + AdultMaleHIV49 + AdultMaleHIV50 + ChildFemaleHIV1 + ChildFemaleHIV4 + ChildFemaleHIV9 + ChildFemaleHIV14 + ChildMaleHIV1 + ChildMaleHIV4 + ChildMaleHIV9 + ChildMaleHIV14; TotalNegative = AdultFemaleHIV19Neg + AdultFemaleHIV24Neg + AdultFemaleHIV49Neg + AdultFemaleHIV50Neg + AdultMaleHIV19Neg + AdultMaleHIV24Neg + AdultMaleHIV49Neg + AdultMaleHIV50Neg + ChildFemaleHIV1Neg + ChildFemaleHIV4Neg + ChildFemaleHIV9Neg + ChildFemaleHIV14Neg + ChildMaleHIV1Neg + ChildMaleHIV4Neg + ChildMaleHIV9Neg + ChildMaleHIV14Neg; TotalTested = FemaleTestedChild1 + FemaleTestedChild4 + FemaleTestedChild9 + FemaleTestedChild14 + FemaleAdultTested19 + FemaleAdultTested24 + FemaleAdultTested49 + FemaleAdultTested50 + MaleAdultTested19 + MaleAdultTested24 + MaleAdultTested49 + MaleAdultTested50 + MaleTestedChild1 + MaleTestedChild4 + MaleTestedChild9 + MaleTestedChild14; TotalPositiveFemale = AdultFemaleHIV19 + AdultFemaleHIV24 + AdultFemaleHIV49 + AdultFemaleHIV50 + ChildFemaleHIV1 + ChildFemaleHIV4 + ChildFemaleHIV9 + ChildFemaleHIV14; TotalPositiveMale = AdultMaleHIV19 + AdultMaleHIV24 + AdultMaleHIV49 + AdultMaleHIV50 + ChildMaleHIV1 + ChildMaleHIV4 + ChildMaleHIV9 + ChildMaleHIV14; //System.out.println(MaleTestedChild14 +" bbbbb "+ChildMaleHIV14+" mmmmm "+ (MaleTestedChild14-ChildMaleHIV14)); rw0.setHeightInPoints(20); c211 = rw0.createCell(0); c212 = rw0.createCell(1); c213 = rw0.createCell(2); c214 = rw0.createCell(3); c215 = rw0.createCell(4); c216 = rw0.createCell(5); c217 = rw0.createCell(6); // the rest c11 = rw0.createCell(7); c12 = rw0.createCell(8); c13 = rw0.createCell(9); c14 = rw0.createCell(10); c15 = rw0.createCell(11); c16 = rw0.createCell(12); c17 = rw0.createCell(13); c18 = rw0.createCell(14); c19 = rw0.createCell(15); c20 = rw0.createCell(16); c110 = rw0.createCell(17); c111 = rw0.createCell(18); c112 = rw0.createCell(19); c113 = rw0.createCell(20); c114 = rw0.createCell(21); c115 = rw0.createCell(22); c116 = rw0.createCell(23); c117 = rw0.createCell(24); //c11.setCellValue(facilname); //String basicDetails=county+"@"+district+"@"+facilityname+"@"+mflcode+"@"+dsdta; c211.setCellValue(county); c212.setCellValue(district); c213.setCellValue(facilityname); c214.setCellValue(mflcode); c215.setCellValue(dsdta); shet3.addMergedRegion(new CellRangeAddress(2, 4, 0, 0)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 1, 1)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 2, 2)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 3, 3)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 4, 4)); // Female c11.setCellValue(TotalTested); c216.setCellValue(TotalPositive); c217.setCellValue(TotalPositiveFemale); shet3.addMergedRegion(new CellRangeAddress(2, 4, 5, 5)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 6, 6)); shet3.addMergedRegion(new CellRangeAddress(3, 4, 7, 7)); c12.setCellValue((float) Math.round(ChildFemaleHIV1)); c13.setCellValue((float) Math.round(ChildFemaleHIV4)); c14.setCellValue((float) Math.round(ChildFemaleHIV9)); c15.setCellValue((float) Math.round(ChildFemaleHIV14)); c16.setCellValue((float) Math.round(AdultFemaleHIV19)); c17.setCellValue((float) Math.round(AdultFemaleHIV24)); c18.setCellValue((float) Math.round(AdultFemaleHIV49)); c19.setCellValue((float) Math.round(AdultFemaleHIV50)); c20.setCellValue(TotalPositiveMale); //male c110.setCellValue((float) Math.round(ChildMaleHIV1)); c111.setCellValue((float) Math.round(ChildMaleHIV4)); c112.setCellValue((float) Math.round(ChildMaleHIV9)); c113.setCellValue((float) Math.round(ChildMaleHIV14)); c114.setCellValue((float) Math.round(AdultMaleHIV19)); c115.setCellValue((float) Math.round(AdultMaleHIV24)); c116.setCellValue((float) Math.round(AdultMaleHIV49)); c117.setCellValue((float) Math.round(AdultMaleHIV50)); for (int i = 0; i <= 22; i++) { c11 = rw0.getCell(i); c11.setCellStyle(stborder); } // shet3.addMergedRegion(new CellRangeAddress(2,5,0,0)); c11 = rw0.createCell(25); c12 = rw0.createCell(26); c13 = rw0.createCell(27); c14 = rw0.createCell(28); c15 = rw0.createCell(29); c16 = rw0.createCell(30); c17 = rw0.createCell(31); c18 = rw0.createCell(32); c19 = rw0.createCell(33); c110 = rw0.createCell(34); c111 = rw0.createCell(35); c112 = rw0.createCell(36); c113 = rw0.createCell(37); c114 = rw0.createCell(38); c115 = rw0.createCell(39); c116 = rw0.createCell(40); c117 = rw0.createCell(41); c118 = rw0.createCell(42); //negative AdultMaleHIV19Neg = (float) Math.round(MaleAdultTested19) - (float) Math.round(AdultMaleHIV19); AdultMaleHIV24Neg = (float) Math.round(MaleAdultTested24) - (float) Math.round(AdultMaleHIV24); AdultMaleHIV49Neg = (float) Math.round(MaleAdultTested49) - (float) Math.round(AdultMaleHIV49); AdultMaleHIV50Neg = (float) Math.round(MaleAdultTested50) - (float) Math.round(AdultMaleHIV50); // child male negatives ChildMaleHIV1Neg = (float) Math.round(MaleTestedChild1) - (float) Math.round(ChildMaleHIV1); ChildMaleHIV4Neg = (float) Math.round(MaleTestedChild4) - (float) Math.round(ChildMaleHIV4); ChildMaleHIV9Neg = (float) Math.round(MaleTestedChild9) - (float) Math.round(ChildMaleHIV9); ChildMaleHIV14Neg = (float) Math.round(MaleTestedChild14) - (float) Math.round(ChildMaleHIV14); //negative ChildFemaleHIV1Neg = (float) Math.round(FemaleTestedChild1) - (float) Math.round(ChildFemaleHIV1); ChildFemaleHIV4Neg = (float) Math.round(FemaleTestedChild4) - (float) Math.round(ChildFemaleHIV4); ChildFemaleHIV9Neg = (float) Math.round(FemaleTestedChild9) - (float) Math.round(ChildFemaleHIV9); ChildFemaleHIV14Neg = (float) Math.round(FemaleTestedChild14) - (float) Math.round(ChildFemaleHIV14); //negative AdultFemaleHIV19Neg = (float) Math.round(FemaleAdultTested19) - (float) Math.round(AdultFemaleHIV19); AdultFemaleHIV24Neg = (float) Math.round(FemaleAdultTested24) - (float) Math.round(AdultFemaleHIV24); AdultFemaleHIV49Neg = (float) Math.round(FemaleAdultTested49) - (float) Math.round(AdultFemaleHIV49); AdultFemaleHIV50Neg = (float) Math.round(FemaleAdultTested50) - (float) Math.round(AdultFemaleHIV50); TotalNegativeFemale = AdultFemaleHIV19Neg + AdultFemaleHIV24Neg + AdultFemaleHIV49Neg + AdultFemaleHIV50Neg + ChildFemaleHIV1Neg + ChildFemaleHIV4Neg + ChildFemaleHIV9Neg + ChildFemaleHIV14Neg; TotalNegativeMale = AdultMaleHIV19Neg + AdultMaleHIV24Neg + AdultMaleHIV49Neg + AdultMaleHIV50Neg + ChildMaleHIV1Neg + ChildMaleHIV4Neg + ChildMaleHIV9Neg + ChildMaleHIV14Neg; c11.setCellValue((float) Math.round(TotalNegativeFemale)); c12.setCellValue((float) Math.round(ChildFemaleHIV1Neg)); c13.setCellValue((float) Math.round(ChildFemaleHIV4Neg)); c14.setCellValue((float) Math.round(ChildFemaleHIV9Neg)); c15.setCellValue((float) Math.round(ChildFemaleHIV14Neg)); c16.setCellValue((float) Math.round(AdultFemaleHIV19Neg)); c17.setCellValue((float) Math.round(AdultFemaleHIV24Neg)); c18.setCellValue((float) Math.round(AdultFemaleHIV49Neg)); c19.setCellValue((float) Math.round(AdultFemaleHIV50Neg)); c110.setCellValue((float) Math.round(TotalNegativeMale)); c111.setCellValue((float) Math.round(ChildMaleHIV1Neg)); c112.setCellValue((float) Math.round(ChildMaleHIV4Neg)); c113.setCellValue((float) Math.round(ChildMaleHIV9Neg)); c114.setCellValue((float) Math.round(ChildMaleHIV14Neg)); c115.setCellValue((float) Math.round(AdultMaleHIV19Neg)); c116.setCellValue((float) Math.round(AdultMaleHIV24Neg)); c117.setCellValue((float) Math.round(AdultMaleHIV49Neg)); c118.setCellValue((float) Math.round(AdultMaleHIV50Neg)); System.out.println(AdultMaleHIV19Neg + "__________" + AdultMaleHIV24Neg + "__________" + AdultMaleHIV49Neg + "__________" + AdultMaleHIV50Neg + "__________" + ChildMaleHIV1Neg + "__________" + ChildMaleHIV4Neg + "__________" + ChildMaleHIV9Neg + "__________" + ChildMaleHIV14Neg); for (int i = 23; i <= 42; i++) { c11 = rw0.getCell(i); c11.setCellStyle(stborder); } // shet3.addMergedRegion(new CellRangeAddress(2,5,20,20)); } } if (conn.st != null) { conn.st.close(); } if (conn.st1 != null) { conn.st1.close(); } if (conn.st2 != null) { conn.st2.close(); } if (conn.rs != null) { conn.rs.close(); } if (conn.rs1 != null) { conn.rs1.close(); } if (conn.rs2 != null) { conn.rs2.close(); } if (conn.conn != null) { conn.conn.close(); } IdGenerator IG = new IdGenerator(); createdOn = IG.CreatedOn(); // write it as an excel attachment ByteArrayOutputStream outByteStream = new ByteArrayOutputStream(); wb.write(outByteStream); byte[] outArray = outByteStream.toByteArray(); response.setContentType("application/ms-excel"); response.setContentLength(outArray.length); response.setHeader("Expires:", "0"); // eliminates browser caching response.setHeader("Content-Disposition", "attachment; filename=moh711_DATIM_REPORT_CREATED_ON_" + createdOn.trim() + ".xls"); OutputStream outStream = response.getOutputStream(); outStream.write(outArray); outStream.flush(); }
From source file:Datim.datimHTCResults.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {/*from www. ja v a 2s.com*/ response.setContentType("text/html;charset=UTF-8"); dbConn conn = new dbConn(); HSSFWorkbook wb = new HSSFWorkbook(); Calendar ca = Calendar.getInstance(); int currentyear = ca.get(Calendar.YEAR); String mwaka = request.getParameter("year"); String facilitiestable = "subpartnera"; int selectedyear = new Integer(mwaka); if (selectedyear < currentyear) { if (selectedyear < 2014) { //db for 2014 is the smallest facilitiestable = "subpartnera2014"; } else { facilitiestable = "subpartnera" + selectedyear; } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //HTC CODE FROM MAUREEN //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (1 == 1) { int less15m = 0; int less15f = 0; int gret15m = 0; int gret15f = 0; ArrayList allFacilities = new ArrayList(); allFacilities.clear(); int year, month, prevYear, maxYearMonth; String reportDuration, duration, semi_annual, quarter; String facilityName, mflcode, countyName, districtName, facilityIds, facilityId; year = month = prevYear = maxYearMonth = 0; reportDuration = duration = semi_annual = quarter = ""; facilityName = mflcode = countyName = districtName = facilityIds = facilityId = ""; String facilityIds1 = ""; facilityIds1 = "("; if (request.getParameter("subcounty") != null && !request.getParameter("subcounty").equals("")) { String subcounty = request.getParameter("subcounty"); String getDist = "SELECT " + facilitiestable + ".SubPartnerID FROM " + facilitiestable + " " + "JOIN district ON " + facilitiestable + ".DistrictID=district.DistrictID " + "WHERE district.DistrictID='" + subcounty + "'"; conn.rs = conn.st.executeQuery(getDist); while (conn.rs.next()) { allFacilities.add(conn.rs.getString(1)); facilityIds1 += " moh711.SubPartnerID='" + conn.rs.getString(1) + "' || "; } facilityIds1 = facilityIds1.substring(0, facilityIds1.length() - 3); facilityIds1 += ") && "; } else { if (request.getParameter("county") != null && !request.getParameter("county").equals("")) { String county = request.getParameter("county"); String getCounty = "SELECT " + facilitiestable + ".SubPartnerID FROM " + facilitiestable + " " + "JOIN district ON " + facilitiestable + ".DistrictID=district.DistrictID " + "JOIN county ON district.CountyID=county.CountyID WHERE county.CountyID='" + county + "'"; conn.rs = conn.st.executeQuery(getCounty); while (conn.rs.next()) { allFacilities.add(conn.rs.getString(1)); facilityIds1 += " moh711.SubPartnerID='" + conn.rs.getString(1) + "' || "; } facilityIds1 = facilityIds1.substring(0, facilityIds1.length() - 3); facilityIds1 += ") && "; } else { facilityIds1 = ""; } } int TestedAdultMale = 0, TestedAdultFemale = 0; int TestedChildMale = 0, TestedChildFemale = 0; int HIV_AdultMale = 0, HIV_AdultFemale = 0; int HIV_ChildMale = 0, HIV_ChildFemale = 0; double FemaleAdultTested; double FemaleTestedChild; double AdultFemaleHIV; double ChildFemaleHIV; double MaleAdultTested; double MaleTestedChild; double AdultMaleHIV; double ChildMaleHIV; double FemaleAdultTested1 = 0; double FemaleAdultTested4 = 0; double FemaleAdultTested9 = 0; double FemaleAdultTested14 = 0; double FemaleAdultTested19 = 0; double FemaleAdultTested24 = 0; double FemaleAdultTested49 = 0; double FemaleAdultTested50 = 0; double FemaleTestedChild1 = 0; double FemaleTestedChild4 = 0; double FemaleTestedChild9 = 0; double FemaleTestedChild14 = 0; double FemaleTestedChild19 = 0; double FemaleTestedChild24 = 0; double FemaleTestedChild49 = 0; double FemaleTestedChild50 = 0; double AdultFemaleHIV19Neg = 0; double AdultFemaleHIV24Neg = 0; double AdultFemaleHIV49Neg = 0; double AdultFemaleHIV50Neg = 0; double AdultFemaleHIV19 = 0; double AdultFemaleHIV24 = 0; double AdultFemaleHIV49 = 0; double AdultFemaleHIV50 = 0; double ChildFemaleHIV1 = 0; double ChildFemaleHIV4 = 0; double ChildFemaleHIV9 = 0; double ChildFemaleHIV14 = 0; double ChildFemaleHIV1Neg = 0; double ChildFemaleHIV4Neg = 0; double ChildFemaleHIV9Neg = 0; double ChildFemaleHIV14Neg = 0; // MALES double MaleAdultTested19Neg = 0; double MaleAdultTested21Neg = 0; double MaleAdultTested49Neg = 0; double MaleAdultTested50Neg = 0; double MaleAdultTested19 = 0; double MaleAdultTested24 = 0; double MaleAdultTested49 = 0; double MaleAdultTested50 = 0; double MaleTestedChild1 = 0; double MaleTestedChild4 = 0; double MaleTestedChild9 = 0; double MaleTestedChild14 = 0; double MaleTestedChild1Neg = 0; double MaleTestedChild4Neg = 0; double MaleTestedChild9Neg = 0; double MaleTestedChild14Neg = 0; double AdultMaleHIV19Neg = 0; double AdultMaleHIV24Neg = 0; double AdultMaleHIV49Neg = 0; double AdultMaleHIV50Neg = 0; double AdultMaleHIV19 = 0; double AdultMaleHIV24 = 0; double AdultMaleHIV49 = 0; double AdultMaleHIV50 = 0; double ChildMaleHIV1 = 0; double ChildMaleHIV4 = 0; double ChildMaleHIV9 = 0; double ChildMaleHIV14 = 0; double ChildMaleHIV1Neg = 0; double ChildMaleHIV4Neg = 0; double ChildMaleHIV9Neg = 0; double ChildMaleHIV14Neg = 0; double splitData = 0; int adderPos = 0; double childSplitData = 0; int redalert = 0; year = Integer.parseInt(request.getParameter("year")); reportDuration = request.getParameter("reportDuration"); // year=2015; // reportDuration="4"; String period1 = ""; String duration1 = ""; prevYear = year - 1; maxYearMonth = 0; // GET REPORT DURATION============================================ if (reportDuration.equals("1")) { duration1 = " moh711.yearmonth BETWEEN " + prevYear + "10 AND " + year + "09"; period1 = "DATIM ANNUAL DATA REPORT FOR PEPFAR YEAR : " + year; } else if (reportDuration.equals("2")) { semi_annual = request.getParameter("semi_annual"); // semi_annual="2"; if (semi_annual.equals("1")) { duration1 = " moh711.yearmonth BETWEEN " + prevYear + "10 AND " + year + "03"; period1 = "DATIM SEMI - ANNUAL DATA REPORT FOR PERIOD : OCT " + prevYear + " to MARCH " + year; } else { duration1 = " moh711.yearmonth BETWEEN " + year + "04 AND " + year + "09"; period1 = "DATIM SEMI - ANNUAL DATA REPORT FOR PERIOD : APRIL " + year + " to SEPT " + year; } } else if (reportDuration.equals("3")) { String startMonth, endMonth; quarter = request.getParameter("quarter"); // quarter="3"; String getMonths = "SELECT months,name FROM quarter WHERE id='" + quarter + "'"; conn.rs = conn.st.executeQuery(getMonths); if (conn.rs.next() == true) { String months[] = conn.rs.getString(1).split(","); startMonth = months[0]; endMonth = months[2]; if (quarter.equals("1")) { duration1 = " moh711.yearmonth BETWEEN " + prevYear + "" + startMonth + " AND " + prevYear + "" + endMonth; period1 = "DATIM QUARTERLY DATA REPORT FOR PERIOD : " + conn.rs.getString(2).replace("-", " " + prevYear + " TO ") + " " + prevYear + ""; } else { duration1 = " moh711.yearmonth BETWEEN " + year + "" + startMonth + " AND " + year + "" + endMonth; period1 = "DATIM QUARTERLY DATA REPORT FOR PERIOD : " + conn.rs.getString(2).replace("-", " " + year + " TO ") + " " + year + ""; } } } else if (reportDuration.equals("4")) { month = Integer.parseInt(request.getParameter("month")); // month=5; String getMonthName = "SELECT name FROM month WHERE id='" + month + "'"; conn.rs = conn.st.executeQuery(getMonthName); if (conn.rs.next() == true) { if (month >= 10) { duration1 = " moh711.yearmonth=" + prevYear + "" + month; period1 = "DATIM MONTHLY DATA REPORT FOR : " + conn.rs.getString(1) + "(" + prevYear + ")"; } else { duration1 = " moh711.yearmonth=" + year + "0" + month; period1 = "DATIM MONTHLY DATA REPORT FOR : " + conn.rs.getString(1) + "(" + year + ")"; } } } else { duration1 = ""; } HSSFSheet shet3 = wb.createSheet("HTC "); HSSFCell c11; FemaleAdultTested = 0; FemaleTestedChild = 0; AdultFemaleHIV = 0; ChildFemaleHIV = 0; double TotalTested = 0; double TotalPositiveFemale = 0; double TotalPositiveMale = 0; double TotalNegativeFemale = 0; double TotalNegativeMale = 0; // MALES MaleAdultTested = 0; MaleTestedChild = 0; AdultMaleHIV = 0; ChildMaleHIV = 0; double TotalPositive = 0; double TotalNegative = 0; String county = ""; String district = ""; String facilityname = ""; HSSFCellStyle stylex = wb.createCellStyle(); stylex.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index); stylex.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); stylex.setBorderTop(HSSFCellStyle.BORDER_THIN); stylex.setBorderBottom(HSSFCellStyle.BORDER_THIN); stylex.setBorderLeft(HSSFCellStyle.BORDER_THIN); stylex.setBorderRight(HSSFCellStyle.BORDER_THIN); stylex.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFFont fontx = wb.createFont(); fontx.setColor(HSSFColor.DARK_BLUE.index); stylex.setFont(fontx); stylex.setWrapText(true); HSSFCellStyle stylemainHeader = wb.createCellStyle(); stylemainHeader.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); stylemainHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); stylemainHeader.setBorderTop(HSSFCellStyle.BORDER_THIN); stylemainHeader.setBorderBottom(HSSFCellStyle.BORDER_THIN); stylemainHeader.setBorderLeft(HSSFCellStyle.BORDER_THIN); stylemainHeader.setBorderRight(HSSFCellStyle.BORDER_THIN); stylemainHeader.setAlignment(HSSFCellStyle.ALIGN_CENTER); stylemainHeader.setWrapText(true); HSSFCellStyle styleHeader = wb.createCellStyle(); styleHeader.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); styleHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); styleHeader.setBorderTop(HSSFCellStyle.BORDER_THIN); styleHeader.setBorderBottom(HSSFCellStyle.BORDER_THIN); styleHeader.setBorderLeft(HSSFCellStyle.BORDER_THIN); styleHeader.setBorderRight(HSSFCellStyle.BORDER_THIN); styleHeader.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleHeader.setWrapText(true); HSSFCellStyle stborder = wb.createCellStyle(); stborder.setBorderTop(HSSFCellStyle.BORDER_THIN); stborder.setBorderBottom(HSSFCellStyle.BORDER_THIN); stborder.setBorderLeft(HSSFCellStyle.BORDER_THIN); stborder.setBorderRight(HSSFCellStyle.BORDER_THIN); stborder.setAlignment(HSSFCellStyle.ALIGN_LEFT); stborder.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); stborder.setWrapText(true); HSSFFont font1 = wb.createFont(); font1.setFontName("Cambria"); font1.setColor((short) 0000); stborder.setFont(font1); // for the red color HSSFCellStyle redstyle = wb.createCellStyle(); redstyle.setFillForegroundColor(HSSFColor.RED.index); redstyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); redstyle.setBorderTop(HSSFCellStyle.BORDER_THIN); redstyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); redstyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); redstyle.setBorderRight(HSSFCellStyle.BORDER_THIN); redstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); redstyle.setWrapText(true); shet3.setColumnWidth(0, 4000); shet3.setColumnWidth(1, 5000); shet3.setColumnWidth(2, 7000); //shet3.setColumnWidth(6,5000); HSSFCell c12, c13, c14, c15, c16, c17, c18, c19, c20, c110, c111, c112, c113, c114, c115, c116, c117, c118, c219; HSSFCell c119, c120, c121, c122, c123, c124, c125, c126, c127, c128, c129, c130, c131, c132, c133, c134, c135, c136, c137; HSSFCell c211, c212, c213, c214, c215, c216, c217, cARTHV, cHTCHV, cPMTCTHV; //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXnew 20160725 //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXnew 20160725 //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXnew 20160725 //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXnew 20160725 String newheader0 = "COUNTY,SUB-COUNTY,FACILITY,MFL-CODE,TYPE OF SUPPORT,ART High Volume,HTC High Volume,PMTCT High Volume,TOTAL HIV+,TOTAL +VE(F),NUM,FEMALE(POSITIVE),,,,,,,,,MALE (POSITIVE),,,,,,,,NEGATIVE,FEMALE (NEGATIVE),,,,,,,,,MALE (NEGATIVE),,,,,,,, ,,,,,,,,"; String newheader1 = "COUNTY,SUB-COUNTY,FACILITY,MFL-CODE,TYPE OF SUPPORT,ART High Volume,HTC High Volume,PMTCT High Volume,TOTAL HIV+,TOTAL +VE(F),NUM,Paeds <15Yr,,,,Adults 15+Yr,,,,TOTAL +VE MALE,Paeds < 15Yr,,,,Adults 15+Yr,,,,TOTAL -VE(F),Paeds <15Yr,,,,Adults 15+Yr,,,,TOTAL -VE(M),Paeds <15Yr,,,,Adults 15+Yr,,,,Female,,Male,,Sub-total,Positive,Negative,Sub-total,Verification Status"; String newheader2 = "COUNTY,SUB-COUNTY,FACILITY,MFL-CODE,TYPE OF SUPPORT,ART High Volume,HTC High Volume,PMTCT High Volume,TOTAL HIV+,TOTAL +VE(F),NUM,<1,1-4Y,5-9Y,10-14Y,15-19Y,20-24Y,25-49Y,50+Y,TOTAL +VE MALE,<1,1-4Y,5-9Y,10-14Y,15-19Y,20-24Y,25-49Y,50+Y,TOTAL -VE(F),<1,1-4Y,5-9Y,10-14Y,15-19Y,20-24Y,25-49Y,50+Y,TOTAL -VE(M),<1,1-4Y,5-9Y,10-14Y,15-19Y,20-24Y,25-49Y,50+Y,< 15,15 +,< 15,15 +,Sub-total,Positive,Negative,Sub-total,Verification Status"; String header0array[] = newheader0.split(","); String header1array[] = newheader1.split(","); String header2array[] = newheader2.split(","); //create header1 HSSFRow rw0 = shet3.createRow(0); rw0.setHeightInPoints(30); HSSFCell c1, c2, c3, c4, c5, c6, c7, c8; c1 = rw0.createCell(0); //_____________________________________________________________report heading row 0 c1.setCellValue(period1); c1.setCellStyle(stylemainHeader); for (int j = 1; j <= header0array.length - 1; j++) { c1 = rw0.createCell(j); c1.setCellStyle(stylemainHeader); } //-----------------------------------row 1 header rw0 = shet3.createRow(2); rw0.setHeightInPoints(30); for (int i = 0; i < header0array.length; i++) { HSSFCell clx = rw0.createCell(i); clx.setCellValue(header0array[i]); clx.setCellStyle(stylemainHeader); } //-----------------------------------row 2 header rw0 = shet3.createRow(3); rw0.setHeightInPoints(30); for (int i = 0; i < header1array.length; i++) { HSSFCell clx = rw0.createCell(i); clx.setCellValue(header1array[i]); clx.setCellStyle(stylemainHeader); } //-----------------------------------row 3 header rw0 = shet3.createRow(4); rw0.setHeightInPoints(30); for (int i = 0; i < header2array.length; i++) { HSSFCell clx = rw0.createCell(i); clx.setCellValue(header2array[i]); clx.setCellStyle(stylemainHeader); } String mergeinfor[] = { "0,0,0,54", "2,4,0,0", "2,4,1,1", "2,4,2,2", "2,4,3,3", "2,4,4,4", "2,4,5,5", "2,4,6,6", "2,4,7,7", "2,4,8,8", "2,4,9,9", "2,4,10,10", "2,2,11,19", "2,2,20,27", "2,2,29,37", "2,2,38,45", "2,2,46,54", "3,3,11,14", "3,3,15,18", "3,3,20,23", "3,3,24,27", "3,3,29,32", "3,3,11,14", "3,3,33,36", "3,3,38,41", "3,3,42,45", "3,3,46,47", "3,3,48,49" }; //do the merging for (int d = 0; d < mergeinfor.length; d++) { if (!mergeinfor[d].equals("")) { String pos[] = mergeinfor[d].split(","); shet3.addMergedRegion(new CellRangeAddress(new Integer(pos[0]), new Integer(pos[1]), new Integer(pos[2]), new Integer(pos[3]))); } } double checkdiff = 0; int count = 4; TestedAdultMale = 0; TestedAdultFemale = 0; TestedChildMale = 0; TestedChildFemale = 0; HIV_AdultMale = 0; HIV_AdultFemale = 0; HIV_ChildMale = 0; HIV_ChildFemale = 0; //--------------------------------------------------------------------------- String facilid = ""; String facilname = ""; String dsdta = ""; String get711data = "SELECT(sum(VCTClient_Tested_CF) +sum( VCTClient_Tested_AF)+sum(DTCB_Test_Out_AF)+sum(DTCB_Test_In_AF))" //ADULTS TESTED FEMALE + ",(sum(VCTClient_Tested_CM)+ sum(VCTClient_Tested_AM) + sum(DTCB_Test_Out_AM) + sum(DTCB_Test_In_AM))"//ADULTS TESTED MALES + ", (sum(VCTClient_HIV_CF)+ sum(VCTClient_HIV_AF)+sum(DTCC_HIV_In_AF)+ sum(DTCC_HIV_Out_AF))" // ADULTS HIV+ FEMALE + ",(sum(VCTClient_HIV_CM)+sum(VCTClient_HIV_AM)+ sum(DTCC_HIV_In_AM) +sum(DTCC_HIV_Out_AM)) " // ADULTS HIV+ MALE + ", (sum(DTCB_Test_Out_CF) + sum(DTCB_Test_In_CF))" // CHILDREN TOTAL TESTED FEMALE + ", (sum(DTCB_Test_Out_CM) + sum(DTCB_Test_In_CM))" // CHILDREN TOTAL TESTED MALE + ", ( sum(DTCC_HIV_In_CF)+ sum(DTCC_HIV_Out_CF))" // CHILDREN POSITIVE FEMALE + ", (sum(DTCC_HIV_In_CM)+ sum(DTCC_HIV_Out_CM)),county.County,district.DistrictNom," + "" + facilitiestable + ".SubPartnerNom," + facilitiestable + ".CentreSanteId," + facilitiestable + ".HTC_Support1 ,ART_highvolume, HTC_highvolume,PMTCT_highvolume"// CHILDREN POSITIVE MALE + " FROM moh711 JOIN " + facilitiestable + " " + "ON moh711.SubPartnerID=" + facilitiestable + ".SubPartnerID " + "JOIN district ON " + facilitiestable + ".DistrictID=district.DistrictID JOIN county ON " + "district.CountyID=county.CountyID" + " WHERE " + " " + facilityIds1 + " " + duration1 + " && " + facilitiestable + ".HTC=1 " + "GROUP BY moh711.SubPartnerID "; System.out.println("711 : " + get711data); conn.rs = conn.st.executeQuery(get711data); while (conn.rs.next()) { String arthv = " "; String htchv = " "; String pmtcthv = " "; if (conn.rs.getString("ART_highvolume") != null) { arthv = conn.rs.getString("ART_highvolume"); } if (conn.rs.getString("HTC_highvolume") != null) { htchv = conn.rs.getString("HTC_highvolume"); } if (conn.rs.getString("PMTCT_highvolume") != null) { pmtcthv = conn.rs.getString("PMTCT_highvolume"); } county = conn.rs.getString(9); district = conn.rs.getString(10); district = district.substring(0, 1).toUpperCase() + district.substring(1).toLowerCase(); facilityname = conn.rs.getString(11); mflcode = conn.rs.getString(12); if (conn.rs.getString("HTC_Support1") == null) { dsdta = "DSD"; } else { dsdta = conn.rs.getString("HTC_Support1"); } TestedAdultFemale = conn.rs.getInt(1); TestedAdultMale = conn.rs.getInt(2); HIV_AdultFemale = conn.rs.getInt(3); HIV_AdultMale = conn.rs.getInt(4); TestedChildFemale = conn.rs.getInt(5); TestedChildMale = conn.rs.getInt(6); HIV_ChildFemale = conn.rs.getInt(7); HIV_ChildMale = conn.rs.getInt(8); System.out.println(facilityname + " KKK " + HIV_AdultFemale + " " + HIV_AdultMale + " " + HIV_ChildFemale + " " + HIV_ChildMale); System.out.println(facilityname + "TestedChildFemale " + TestedChildFemale + " HIV_ChildFemale " + HIV_ChildFemale + " TestedChildMale " + TestedChildMale + " HIV_ChildMale " + HIV_ChildMale); String basicDetails = county + "@" + district + "@" + facilityname + "@" + mflcode + "@" + dsdta; String arrayDetails[] = basicDetails.split("@"); count++; rw0 = shet3.createRow(count); int facilno = 0; for (int j = 0; j < arrayDetails.length; j++) { HSSFCell S3cell = rw0.createCell(facilno); S3cell.setCellValue(arrayDetails[j]); // System.out.println(arrayDetails[j]); S3cell.setCellStyle(stborder); System.out.println("facildet pos : " + facilno + " det : " + arrayDetails[j]); facilno++; } System.out.println(facilityname + " TestedAdultFemale " + TestedAdultFemale + "TestedAdultMale " + TestedAdultMale + " TestedChildFemale " + TestedChildFemale + " TestedChildMale " + TestedChildMale + " HIV_AdultFemale " + HIV_AdultFemale + " HIV_AdultMale " + HIV_AdultMale + " HIV_ChildFemale " + HIV_ChildFemale + " HIV_ChildMale " + HIV_ChildMale); // FEMALES FemaleAdultTested19 = (float) Math.round((0.05 * TestedAdultFemale)); FemaleAdultTested24 = (float) Math.round((0.11 * TestedAdultFemale)); FemaleAdultTested49 = (float) Math.round((0.72 * TestedAdultFemale)); FemaleAdultTested50 = (float) Math.round((0.12 * TestedAdultFemale)); FemaleTestedChild1 = (float) Math.round((0.05 * TestedChildFemale)); FemaleTestedChild4 = (float) Math.round((0.26 * TestedChildFemale)); FemaleTestedChild9 = (float) Math.round((0.29 * TestedChildFemale)); FemaleTestedChild14 = (float) Math.round((0.40 * TestedChildFemale)); //postive AdultFemaleHIV19 = (float) Math.round((0.02 * HIV_AdultFemale)); AdultFemaleHIV24 = (float) Math.round((0.09 * HIV_AdultFemale)); AdultFemaleHIV49 = (float) Math.round((0.79 * HIV_AdultFemale)); AdultFemaleHIV50 = (float) Math.round((0.10 * HIV_AdultFemale)); //positve ChildFemaleHIV1 = (float) Math.round((0.13 * HIV_ChildFemale)); ChildFemaleHIV4 = (float) Math.round((0.37 * HIV_ChildFemale)); ChildFemaleHIV9 = (float) Math.round((0.25 * HIV_ChildFemale)); ChildFemaleHIV14 = (float) Math.round((0.25 * HIV_ChildFemale)); // MALES MaleAdultTested19 = (float) Math.round((0.05 * TestedAdultMale)); MaleAdultTested24 = (float) Math.round((0.11 * TestedAdultMale)); MaleAdultTested49 = (float) Math.round((0.72 * TestedAdultMale)); MaleAdultTested50 = (float) Math.round((0.12 * TestedAdultMale)); MaleTestedChild1 = (float) Math.round((0.05 * TestedChildMale)); MaleTestedChild4 = (float) Math.round((0.26 * TestedChildMale)); MaleTestedChild9 = (float) Math.round((0.29 * TestedChildMale)); MaleTestedChild14 = (float) Math.round((0.40 * TestedChildMale)); //positive AdultMaleHIV19 = (float) Math.round((0.02 * HIV_AdultMale)); AdultMaleHIV24 = (float) Math.round((0.09 * HIV_AdultMale)); AdultMaleHIV49 = (float) Math.round((0.79 * HIV_AdultMale)); AdultMaleHIV50 = (float) Math.round((0.10 * HIV_AdultMale)); //positives ChildMaleHIV1 = (float) Math.round((0.13 * HIV_ChildMale)); ChildMaleHIV4 = (float) Math.round((0.37 * HIV_ChildMale)); ChildMaleHIV9 = (float) Math.round((0.25 * HIV_ChildMale)); ChildMaleHIV14 = (float) Math.round((0.25 * HIV_ChildMale)); // TestedAdultFemale=conn.rs.getInt(1); // TestedAdultMale=conn.rs.getInt(2); // HIV_AdultFemale=conn.rs.getInt(3); // HIV_AdultMale=conn.rs.getInt(4); // TestedChildFemale=conn.rs.getInt(5); // TestedChildMale=conn.rs.getInt(6); // HIV_ChildFemale=conn.rs.getInt(7); // HIV_ChildMale=conn.rs.getInt(8); // TotalTested=FemaleTestedChild1+FemaleTestedChild4+FemaleTestedChild9+FemaleTestedChild14+FemaleAdultTested19+FemaleAdultTested24+FemaleAdultTested49+FemaleAdultTested50+ MaleAdultTested19+MaleAdultTested24+MaleAdultTested49+MaleAdultTested50+MaleTestedChild1+MaleTestedChild4+MaleTestedChild9+MaleTestedChild14; double totalpositivesmale = 0; double totalpositivesfemale = 0; double totalpositives = 0; double totalnegatives = 0; double totalfemalehiv = 0; double totalmalehiv = 0; double totalfemaletesteddis = 0; double totalmaletesteddis = 0; double totalfemaletested = 0; double totalmaletested = 0; double negfem = 0; double negmale = 0; int redalert1 = 0; int redalert2 = 0; int redalert3 = 0; int redalert4 = 0; totalpositives = AdultFemaleHIV19 + AdultFemaleHIV24 + AdultFemaleHIV49 + AdultFemaleHIV50 + ChildFemaleHIV1 + ChildFemaleHIV4 + ChildFemaleHIV9 + ChildFemaleHIV14 + AdultMaleHIV19 + AdultMaleHIV24 + AdultMaleHIV49 + AdultMaleHIV50 + ChildMaleHIV1 + ChildMaleHIV4 + ChildMaleHIV9 + ChildMaleHIV14; totalnegatives = AdultFemaleHIV19Neg + AdultFemaleHIV24Neg + AdultFemaleHIV49Neg + AdultFemaleHIV50Neg + ChildFemaleHIV1Neg + ChildFemaleHIV4Neg + ChildFemaleHIV9Neg + ChildFemaleHIV14Neg + AdultMaleHIV19Neg + AdultMaleHIV24Neg + AdultMaleHIV49Neg + AdultMaleHIV50Neg + ChildMaleHIV1Neg + ChildMaleHIV4Neg + ChildMaleHIV9Neg + ChildMaleHIV14Neg; // total tested after distribution totalfemaletesteddis = FemaleTestedChild1 + FemaleTestedChild4 + FemaleTestedChild9 + FemaleTestedChild14 + FemaleAdultTested19 + FemaleAdultTested24 + FemaleAdultTested49 + FemaleAdultTested50; totalmaletesteddis = MaleAdultTested19 + MaleAdultTested24 + MaleAdultTested49 + MaleAdultTested50 + MaleTestedChild1 + MaleTestedChild4 + MaleTestedChild9 + MaleTestedChild14; // totaltested after distriibution double totaltestedis = 0; totaltestedis = totalfemaletesteddis + totalmaletesteddis; TotalTested = TestedChildFemale + TestedChildMale + TestedAdultMale + TestedAdultFemale; totalfemaletested = TestedAdultFemale + TestedChildFemale; totalmaletested = TestedAdultMale + TestedChildMale; //poistives totalfemalehiv = HIV_AdultFemale + HIV_ChildFemale; totalmalehiv = HIV_AdultMale + HIV_ChildMale; //+ve after dist totalpositivesfemale = AdultFemaleHIV19 + AdultFemaleHIV24 + AdultFemaleHIV49 + AdultFemaleHIV50 + ChildFemaleHIV1 + ChildFemaleHIV4 + ChildFemaleHIV9 + ChildFemaleHIV14; totalpositivesmale = AdultMaleHIV19 + AdultMaleHIV24 + AdultMaleHIV49 + AdultMaleHIV50 + ChildMaleHIV1 + ChildMaleHIV4 + ChildMaleHIV9 + ChildMaleHIV14; // // negative negfem = totalfemaletested - totalfemalehiv; negmale = totalmaletested - totalmalehiv; double checkdiff1 = 0; double checkdiff2 = 0; double checkdiff3 = 0; int redfemalealert = 0; int redmalealert = 0; int finalalert = 0; double totalcheckdiff = 0; checkdiff = totalfemalehiv - totalpositivesfemale; // System.out.println("checkdiff female "+checkdiff1); // positive female if (checkdiff > 2 || checkdiff < -2) { redalert = 1; } // positive male checkdiff1 = totalmalehiv - totalpositivesmale; // System.out.println("checkdiff male "+checkdiff1); if (checkdiff1 > 2 || checkdiff1 < -2) { redalert1 = 1; } totalcheckdiff = TotalTested - totaltestedis; // System.out.println("dqa "+totalcheckdiff); if (totalcheckdiff > 5 || totalcheckdiff < -5) { finalalert = 1; } // checkdiff=totalfemalehiv-totalpositivesfemale; // // positive female // if(checkdiff>=2 ||checkdiff<=-2){ // redalert=1; // } // // positive male // checkdiff1=totalmalehiv-totalpositivesmale; // if(checkdiff1>=2 ||checkdiff1<=-2){ // redalert1=1; // } //// negative female // checkdiff2=negfem-totalfemaletesteddis; // if(checkdiff2>=2 ||checkdiff2<=-2){ // redalert2=1; // } // // // negativemale // checkdiff3=negmale-totalmaletesteddis; // if(checkdiff3>=2 ||checkdiff3<=-2){ // redalert3=1; // } // // totalcheckdiff=checkdiff+checkdiff1+checkdiff2+checkdiff3; // if(totalcheckdiff>=5 || totalcheckdiff<=-5){ // finalalert=1; // } adderPos = 0; double Totalhivfemale = 0; double Totalhivmale = 0; Totalhivfemale = HIV_AdultFemale + HIV_ChildFemale; Totalhivmale = HIV_AdultMale + HIV_ChildMale; splitData = 0; adderPos = 0; childSplitData = 0; // // adult female hiv+ splitData = AdultFemaleHIV19 + AdultFemaleHIV24 + AdultFemaleHIV49 + AdultFemaleHIV50; // System.out.println(facilityname + " lllll added " + splitData + " from db " + HIV_AdultFemale); adderPos = 0; while (splitData < HIV_AdultFemale) { AdultFemaleHIV49 += 1; splitData++; } splitData = AdultFemaleHIV19 + AdultFemaleHIV24 + AdultFemaleHIV49 + AdultFemaleHIV50; while (splitData > HIV_AdultFemale) { AdultFemaleHIV49 -= 1; splitData--; } //tested female adults splitData = FemaleAdultTested19 + FemaleAdultTested24 + FemaleAdultTested49 + FemaleAdultTested50; adderPos = 0; while (splitData < TestedAdultFemale) { FemaleAdultTested49 += 1; splitData++; } splitData = FemaleAdultTested19 + FemaleAdultTested24 + FemaleAdultTested49 + FemaleAdultTested50; adderPos = 0; while (splitData > TestedAdultFemale) { FemaleAdultTested49 -= 1; splitData--; } // adult male hiv+ splitData = AdultMaleHIV19 + AdultMaleHIV24 + AdultMaleHIV49 + AdultMaleHIV50; adderPos = 0; while (splitData < HIV_AdultMale) { AdultMaleHIV49 += 1; splitData++; } splitData = AdultMaleHIV19 + AdultMaleHIV24 + AdultMaleHIV49 + AdultMaleHIV50; adderPos = 0; while (splitData > HIV_AdultMale) { AdultMaleHIV49 -= 1; splitData--; } //tested male adults splitData = MaleAdultTested19 + MaleAdultTested24 + MaleAdultTested49 + MaleAdultTested50; adderPos = 0; while (splitData < TestedAdultMale) { MaleAdultTested49 += 1; splitData++; } splitData = MaleAdultTested19 + MaleAdultTested24 + MaleAdultTested49 + MaleAdultTested50; adderPos = 0; while (splitData > TestedAdultMale) { MaleAdultTested49 -= 1; splitData--; } // for child female tested childSplitData = FemaleTestedChild1 + FemaleTestedChild4 + FemaleTestedChild9 + FemaleTestedChild14; System.out.println(facilityname + " " + childSplitData + " b4 jjj " + TestedChildFemale); adderPos = 0; while (childSplitData < TestedChildFemale) { if (adderPos == 0) { FemaleTestedChild14 += 1; } if (adderPos == 1) { FemaleTestedChild9 += 1; } if (adderPos == 2) { FemaleTestedChild4 += 1; } childSplitData++; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == TestedChildFemale) { } } childSplitData = FemaleTestedChild1 + FemaleTestedChild4 + FemaleTestedChild9 + FemaleTestedChild14; adderPos = 0; while (childSplitData > TestedChildFemale) { if (adderPos == 0) { FemaleTestedChild14 -= 1; } if (adderPos == 1) { FemaleTestedChild9 -= 1; } if (adderPos == 2) { FemaleTestedChild4 -= 1; } childSplitData--; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == TestedChildFemale) { } } System.out.println(facilityname + " " + childSplitData + " after jjj " + TestedChildFemale); // for child male hiv // for child female +ve childSplitData = ChildFemaleHIV1 + ChildFemaleHIV4 + ChildFemaleHIV9 + ChildFemaleHIV14; System.out.println(facilityname + " mmmm " + childSplitData + " " + HIV_ChildFemale); adderPos = 0; double diff = 0; while (childSplitData < HIV_ChildFemale) { diff = FemaleTestedChild14 - ChildFemaleHIV14; if (adderPos == 0) { if (FemaleTestedChild14 - ChildFemaleHIV14 > 0) { ChildFemaleHIV14 += 1; } else if (FemaleTestedChild9 - ChildFemaleHIV9 > 0) { ChildFemaleHIV9 += 1; } else if (FemaleTestedChild4 - ChildFemaleHIV4 > 0) { ChildFemaleHIV4 += 1; } } if (adderPos == 1) { if (FemaleTestedChild9 - ChildFemaleHIV9 > 0) { ChildFemaleHIV9 += 1; } else if (FemaleTestedChild4 - ChildFemaleHIV4 > 0) { ChildFemaleHIV4 += 1; } else if (FemaleTestedChild14 - ChildFemaleHIV14 > 0) { ChildFemaleHIV14 += 1; } } if (adderPos == 2) { if (FemaleTestedChild4 - ChildFemaleHIV4 > 0) { ChildFemaleHIV4 += 1; } else if (FemaleTestedChild14 - ChildFemaleHIV14 > 0) { ChildFemaleHIV14 += 1; } else if (FemaleTestedChild9 - ChildFemaleHIV9 > 0) { ChildFemaleHIV9 += 1; } } childSplitData++; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == HIV_ChildFemale) { } } childSplitData = ChildFemaleHIV1 + ChildFemaleHIV4 + ChildFemaleHIV9 + ChildFemaleHIV14; adderPos = 0; while (childSplitData > HIV_ChildFemale) { if (adderPos == 0) { ChildFemaleHIV14 -= 1; } if (adderPos == 1) { ChildFemaleHIV9 -= 1; } if (adderPos == 2) { ChildFemaleHIV4 -= 1; } childSplitData--; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == HIV_ChildFemale) { } } // tested male _______________________________________________________________________ childSplitData = MaleTestedChild1 + MaleTestedChild4 + MaleTestedChild9 + MaleTestedChild14; adderPos = 0; while (childSplitData < TestedChildMale) { if (adderPos == 0) { MaleTestedChild14 += 1; } else if (adderPos == 1) { MaleTestedChild9 += 1; } else if (adderPos == 2) { MaleTestedChild4 += 1; } childSplitData++; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == TestedChildMale) { } } childSplitData = MaleTestedChild1 + MaleTestedChild4 + MaleTestedChild9 + MaleTestedChild14; adderPos = 0; while (childSplitData > TestedChildMale) { if (adderPos == 0) { MaleTestedChild14 -= 1; } else if (adderPos == 1) { MaleTestedChild9 -= 1; } else if (adderPos == 2) { MaleTestedChild4 -= 1; } childSplitData--; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == TestedChildMale) { } } // for child male +ve childSplitData = ChildMaleHIV1 + ChildMaleHIV4 + ChildMaleHIV9 + ChildMaleHIV14; adderPos = 0; while (childSplitData < HIV_ChildMale) { if (adderPos == 0) { if (MaleTestedChild14 - ChildMaleHIV14 > 0) { ChildMaleHIV14 += 1; } else if (MaleTestedChild9 - ChildMaleHIV9 > 0) { ChildMaleHIV9 += 1; } else if (MaleTestedChild4 - ChildMaleHIV4 > 0) { ChildMaleHIV4 += 1; } } else if (adderPos == 1) { if (MaleTestedChild9 - ChildMaleHIV9 > 0) { ChildMaleHIV9 += 1; } else if (MaleTestedChild4 - ChildMaleHIV4 > 0) { ChildMaleHIV4 += 1; } else if (MaleTestedChild14 - ChildMaleHIV14 > 0) { ChildMaleHIV14 += 1; } } if (adderPos == 2) { if (MaleTestedChild4 - ChildMaleHIV4 > 0) { ChildMaleHIV4 += 1; } else if (MaleTestedChild14 - ChildMaleHIV14 > 0) { ChildMaleHIV14 += 1; } else if (MaleTestedChild9 - ChildMaleHIV9 > 0) { ChildMaleHIV9 += 1; } } childSplitData++; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == HIV_ChildMale) { } } childSplitData = ChildMaleHIV1 + ChildMaleHIV4 + ChildMaleHIV9 + ChildMaleHIV14; adderPos = 0; while (childSplitData > HIV_ChildMale) { if (adderPos == 0) { ChildMaleHIV14 -= 1; } else if (adderPos == 1) { ChildMaleHIV9 -= 1; } if (adderPos == 2) { ChildMaleHIV4 -= 1; } childSplitData--; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == HIV_ChildMale) { } } /// // System.out.println("Neg nn "+ChildMaleHIV1Neg+ " "+ChildMaleHIV4Neg+" "+ChildMaleHIV9Neg+" "+ ChildMaleHIV14Neg); // System.out.println("tested nn "+MaleTestedChild1+ " "+MaleTestedChild4+" "+MaleTestedChild9+" "+ MaleTestedChild14); // System.out.println("hiv+ nnn "+ChildMaleHIV1+ " "+ChildMaleHIV4+" "+ChildMaleHIV9+" "+ ChildMaleHIV14); // // all positives //TotalPositive=AdultFemaleHIV19+AdultFemaleHIV24+AdultFemaleHIV49+AdultFemaleHIV50+AdultMaleHIV19+AdultMaleHIV24+AdultMaleHIV49+AdultMaleHIV50+ // ChildFemaleHIV1+ChildFemaleHIV4+ChildFemaleHIV9+ChildFemaleHIV14 +ChildMaleHIV1+ChildMaleHIV4+ChildMaleHIV9+ChildMaleHIV14; // //TotalNegative=AdultFemaleHIV19Neg+AdultFemaleHIV24Neg+AdultFemaleHIV49Neg+AdultFemaleHIV50Neg+AdultMaleHIV19Neg+AdultMaleHIV24Neg+AdultMaleHIV49Neg+AdultMaleHIV50Neg+ // ChildFemaleHIV1Neg+ChildFemaleHIV4Neg+ChildFemaleHIV9Neg+ChildFemaleHIV14Neg +ChildMaleHIV1Neg+ChildMaleHIV4Neg+ChildMaleHIV9Neg+ChildMaleHIV14Neg; System.out.println(facilityname + " KKK " + HIV_AdultFemale + " " + HIV_AdultMale + " " + HIV_ChildFemale + " " + HIV_ChildMale); System.out.println(facilityname + "TestedChildFemale " + TestedChildFemale + " HIV_ChildFemale " + HIV_ChildFemale + " TestedChildMale " + TestedChildMale + " HIV_ChildMale " + HIV_ChildMale); double totaltestedmale1 = 0; double totaltestedfemale1 = 0; TotalTested = TestedChildFemale + TestedChildMale + TestedAdultMale + TestedAdultFemale; totaltestedmale1 = TestedChildMale + TestedAdultMale; totaltestedfemale1 = TestedChildFemale + TestedAdultFemale; TotalPositiveFemale = HIV_ChildFemale + HIV_AdultFemale; TotalPositiveMale = HIV_ChildMale + HIV_AdultMale; TotalPositive = HIV_ChildFemale + HIV_AdultFemale + HIV_ChildMale + HIV_AdultMale; TotalNegativeFemale = totaltestedfemale1 - TotalPositiveFemale; TotalNegativeMale = totaltestedmale1 - TotalPositiveMale; TotalNegative = TotalNegativeMale + TotalNegativeFemale; //201510 //this code was added later less15f = TestedChildFemale; less15m = TestedChildMale; gret15m = TestedAdultMale; gret15f = TestedAdultFemale; // TotalNegativeFemale=AdultFemaleHIV19Neg+AdultFemaleHIV24Neg+AdultFemaleHIV49Neg+AdultFemaleHIV50Neg+ ChildFemaleHIV1Neg+ChildFemaleHIV4Neg+ChildFemaleHIV9Neg+ChildFemaleHIV14Neg; //TotalNegativeMale=AdultMaleHIV19Neg+AdultMaleHIV24Neg+AdultMaleHIV49Neg+AdultMaleHIV50Neg+ChildMaleHIV1Neg+ChildMaleHIV4Neg+ChildMaleHIV9Neg+ChildMaleHIV14Neg; // TotalTested=FemaleTestedChild1+FemaleTestedChild4+FemaleTestedChild9+FemaleTestedChild14+FemaleAdultTested19+FemaleAdultTested24+FemaleAdultTested49+FemaleAdultTested50+ MaleAdultTested19+MaleAdultTested24+MaleAdultTested49+MaleAdultTested50+MaleTestedChild1+MaleTestedChild4+MaleTestedChild9+MaleTestedChild14; // TotalPositiveFemale=AdultFemaleHIV19+AdultFemaleHIV24+AdultFemaleHIV49+AdultFemaleHIV50+ChildFemaleHIV1+ChildFemaleHIV4+ChildFemaleHIV9+ChildFemaleHIV14 ; // TotalPositiveMale=AdultMaleHIV19+AdultMaleHIV24+AdultMaleHIV49+AdultMaleHIV50+ChildMaleHIV1+ChildMaleHIV4+ChildMaleHIV9+ChildMaleHIV14; // //System.out.println(MaleTestedChild14 +" bbbbb "+ChildMaleHIV14+" mmmmm "+ (MaleTestedChild14-ChildMaleHIV14)); rw0.setHeightInPoints(25); int mypos = 0; c211 = rw0.createCell(mypos); mypos++; c212 = rw0.createCell(mypos); mypos++; c213 = rw0.createCell(mypos); mypos++; c214 = rw0.createCell(mypos); mypos++; c215 = rw0.createCell(mypos); mypos++; cARTHV = rw0.createCell(mypos); mypos++; cARTHV.setCellValue(arthv); cHTCHV = rw0.createCell(mypos); mypos++; cHTCHV.setCellValue(htchv); cPMTCTHV = rw0.createCell(mypos); mypos++; cPMTCTHV.setCellValue(pmtcthv); c216 = rw0.createCell(mypos); mypos++; c217 = rw0.createCell(mypos); mypos++; // the rest c11 = rw0.createCell(mypos); mypos++; c12 = rw0.createCell(mypos); mypos++; c13 = rw0.createCell(mypos); mypos++; c14 = rw0.createCell(mypos); mypos++; c15 = rw0.createCell(mypos); mypos++; c16 = rw0.createCell(mypos); mypos++; c17 = rw0.createCell(mypos); mypos++; c18 = rw0.createCell(mypos); mypos++; c19 = rw0.createCell(mypos); mypos++; c20 = rw0.createCell(mypos); mypos++; c110 = rw0.createCell(mypos); mypos++; c111 = rw0.createCell(mypos); mypos++; c112 = rw0.createCell(mypos); mypos++; c113 = rw0.createCell(mypos); mypos++; c114 = rw0.createCell(mypos); mypos++; c115 = rw0.createCell(mypos); mypos++; c116 = rw0.createCell(mypos); mypos++; c117 = rw0.createCell(mypos); mypos++; //c11.setCellValue(facilname); //String basicDetails=county+"@"+district+"@"+facilityname+"@"+mflcode+"@"+dsdta; c211.setCellValue(county); c212.setCellValue(district); c213.setCellValue(facilityname); c214.setCellValue(mflcode); c215.setCellValue(dsdta); shet3.addMergedRegion(new CellRangeAddress(2, 4, 0, 0)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 1, 1)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 2, 2)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 3, 3)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 4, 4)); // Female c11.setCellValue(TotalTested); c216.setCellValue(TotalPositive); c217.setCellValue(TotalPositiveFemale); shet3.addMergedRegion(new CellRangeAddress(2, 4, 5, 5)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 6, 6)); shet3.addMergedRegion(new CellRangeAddress(3, 4, 7, 7)); c12.setCellValue((float) Math.round(ChildFemaleHIV1)); c13.setCellValue((float) Math.round(ChildFemaleHIV4)); c14.setCellValue((float) Math.round(ChildFemaleHIV9)); c15.setCellValue((float) Math.round(ChildFemaleHIV14)); c16.setCellValue((float) Math.round(AdultFemaleHIV19)); c17.setCellValue((float) Math.round(AdultFemaleHIV24)); c18.setCellValue((float) Math.round(AdultFemaleHIV49)); c19.setCellValue((float) Math.round(AdultFemaleHIV50)); c20.setCellValue(TotalPositiveMale); //male c110.setCellValue((float) Math.round(ChildMaleHIV1)); c111.setCellValue((float) Math.round(ChildMaleHIV4)); c112.setCellValue((float) Math.round(ChildMaleHIV9)); c113.setCellValue((float) Math.round(ChildMaleHIV14)); c114.setCellValue((float) Math.round(AdultMaleHIV19)); c115.setCellValue((float) Math.round(AdultMaleHIV24)); c116.setCellValue((float) Math.round(AdultMaleHIV49)); c117.setCellValue((float) Math.round(AdultMaleHIV50)); for (int i = 0; i <= 22; i++) { c11 = rw0.getCell(i); c11.setCellStyle(stborder); // System.out.println("red "+redalert +" "+redalert1) ; if (redalert == 1) { c217 = rw0.getCell(6); c217.setCellStyle(redstyle); } if (redalert1 == 1) { c20 = rw0.getCell(16); c20.setCellStyle(redstyle); } } // shet3.addMergedRegion(new CellRangeAddress(2,5,0,0)); c11 = rw0.createCell(mypos); mypos++; c12 = rw0.createCell(mypos); mypos++; c13 = rw0.createCell(mypos); mypos++; c14 = rw0.createCell(mypos); mypos++; c15 = rw0.createCell(mypos); mypos++; c16 = rw0.createCell(mypos); mypos++; c17 = rw0.createCell(mypos); mypos++; c18 = rw0.createCell(mypos); mypos++; c19 = rw0.createCell(mypos); mypos++; c110 = rw0.createCell(mypos); mypos++; c111 = rw0.createCell(mypos); mypos++; c112 = rw0.createCell(mypos); mypos++; c113 = rw0.createCell(mypos); mypos++; c114 = rw0.createCell(mypos); mypos++; c115 = rw0.createCell(mypos); mypos++; c116 = rw0.createCell(mypos); mypos++; c117 = rw0.createCell(mypos); mypos++; c118 = rw0.createCell(mypos); mypos++; c119 = rw0.createCell(mypos); mypos++; int neg1male = 0; int neg4male = 0; int neg9male = 0; int neg14male = 0; int neg19male = 0; int neg24male = 0; int neg49male = 0; int neg50male = 0; AdultMaleHIV19Neg = (float) Math.round(MaleAdultTested19) - (AdultMaleHIV19); AdultMaleHIV24Neg = (float) Math.round(MaleAdultTested24) - (AdultMaleHIV24); AdultMaleHIV49Neg = (float) Math.round(MaleAdultTested49) - (AdultMaleHIV49); AdultMaleHIV50Neg = (float) Math.round(MaleAdultTested50) - (AdultMaleHIV50); if (AdultMaleHIV19Neg <= -1) { neg19male = 1; } if (AdultMaleHIV24Neg <= -1) { neg24male = 1; } if (AdultMaleHIV49Neg <= -1) { neg49male = 1; } if (AdultMaleHIV50Neg <= -1) { neg50male = 1; } // child male negatives ChildMaleHIV1Neg = (float) Math.round(MaleTestedChild1) - (ChildMaleHIV1); ChildMaleHIV4Neg = (float) Math.round(MaleTestedChild4) - (ChildMaleHIV4); ChildMaleHIV9Neg = (float) Math.round(MaleTestedChild9) - (ChildMaleHIV9); ChildMaleHIV14Neg = (float) Math.round(MaleTestedChild14) - (ChildMaleHIV14); if (ChildMaleHIV1Neg <= -1) { neg1male = 1; } if (ChildMaleHIV4Neg <= -1) { neg4male = 1; } if (ChildMaleHIV9Neg <= -1) { neg9male = 1; } if (ChildMaleHIV14Neg <= -1) { neg14male = 1; } //negative int neg1female = 0; int neg4female = 0; int neg9female = 0; int neg14female = 0; int neg19female = 0; int neg24female = 0; int neg49female = 0; int neg50female = 0; ChildFemaleHIV1Neg = (float) Math.round(FemaleTestedChild1) - (ChildFemaleHIV1); ChildFemaleHIV4Neg = (float) Math.round(FemaleTestedChild4) - (ChildFemaleHIV4); ChildFemaleHIV9Neg = (float) Math.round(FemaleTestedChild9) - (ChildFemaleHIV9); ChildFemaleHIV14Neg = (float) Math.round(FemaleTestedChild14) - (ChildFemaleHIV14); if (ChildFemaleHIV1Neg <= -1) { neg1female = 1; } if (ChildFemaleHIV4Neg <= -1) { neg4female = 1; } if (ChildFemaleHIV9Neg <= -1) { neg9female = 1; } if (ChildFemaleHIV14Neg <= -1) { neg14female = 1; } System.out.println(facilityname + " fffff " + ChildFemaleHIV1Neg + " " + ChildFemaleHIV4Neg + " " + ChildFemaleHIV9Neg + " " + ChildFemaleHIV14Neg); //negative AdultFemaleHIV19Neg = (float) Math.round(FemaleAdultTested19) - (AdultFemaleHIV19); AdultFemaleHIV24Neg = (float) Math.round(FemaleAdultTested24) - (AdultFemaleHIV24); AdultFemaleHIV49Neg = (float) Math.round(FemaleAdultTested49) - (AdultFemaleHIV49); AdultFemaleHIV50Neg = (float) Math.round(FemaleAdultTested50) - (AdultFemaleHIV50); if (AdultFemaleHIV19Neg <= -1) { neg19female = 1; } if (AdultFemaleHIV24Neg <= -1) { neg24female = 1; } if (AdultFemaleHIV49Neg <= -1) { neg49female = 1; } if (AdultFemaleHIV50Neg <= -1) { neg50female = 1; } double TotalNegativeFemale1 = 0; double TotalNegativeMale1 = 0; TotalNegativeFemale1 = AdultFemaleHIV19Neg + AdultFemaleHIV24Neg + AdultFemaleHIV49Neg + AdultFemaleHIV50Neg + ChildFemaleHIV1Neg + ChildFemaleHIV4Neg + ChildFemaleHIV9Neg + ChildFemaleHIV14Neg; TotalNegativeMale1 = AdultMaleHIV19Neg + AdultMaleHIV24Neg + AdultMaleHIV49Neg + AdultMaleHIV50Neg + ChildMaleHIV1Neg + ChildMaleHIV4Neg + ChildMaleHIV9Neg + ChildMaleHIV14Neg; // negative female checkdiff2 = negfem - TotalNegativeFemale1; if (checkdiff2 > 2 || checkdiff2 < -2) { redalert2 = 1; } // negativemale checkdiff3 = negmale - TotalNegativeMale1; if (checkdiff3 > 2 || checkdiff3 < -2) { redalert3 = 1; } c11.setCellValue((float) Math.round(TotalNegativeFemale)); c12.setCellValue((float) Math.round(ChildFemaleHIV1Neg)); c13.setCellValue((float) Math.round(ChildFemaleHIV4Neg)); c14.setCellValue((float) Math.round(ChildFemaleHIV9Neg)); c15.setCellValue((float) Math.round(ChildFemaleHIV14Neg)); c16.setCellValue((float) Math.round(AdultFemaleHIV19Neg)); c17.setCellValue((float) Math.round(AdultFemaleHIV24Neg)); c18.setCellValue((float) Math.round(AdultFemaleHIV49Neg)); c19.setCellValue((float) Math.round(AdultFemaleHIV50Neg)); c110.setCellValue((float) Math.round(TotalNegativeMale)); c111.setCellValue((float) Math.round(ChildMaleHIV1Neg)); c112.setCellValue((float) Math.round(ChildMaleHIV4Neg)); c113.setCellValue((float) Math.round(ChildMaleHIV9Neg)); c114.setCellValue((float) Math.round(ChildMaleHIV14Neg)); c115.setCellValue((float) Math.round(AdultMaleHIV19Neg)); c116.setCellValue((float) Math.round(AdultMaleHIV24Neg)); c117.setCellValue((float) Math.round(AdultMaleHIV49Neg)); c117.setCellStyle(stborder); c118.setCellValue((float) Math.round(AdultMaleHIV50Neg)); c118.setCellStyle(stborder); c119.setCellValue(less15f); c119.setCellStyle(stborder); c120 = rw0.createCell(mypos); mypos++; c120.setCellStyle(stborder); c121 = rw0.createCell(mypos); mypos++; c121.setCellStyle(stborder); c122 = rw0.createCell(mypos); mypos++; c122.setCellStyle(stborder); c123 = rw0.createCell(mypos); mypos++; c123.setCellStyle(stborder); c124 = rw0.createCell(mypos); mypos++; c124.setCellStyle(stborder); c125 = rw0.createCell(mypos); mypos++; c125.setCellStyle(stborder); c126 = rw0.createCell(mypos); mypos++; c126.setCellStyle(stborder); c127 = rw0.createCell(mypos); mypos++; c127.setCellStyle(stborder); c128 = rw0.createCell(mypos); mypos++; c120.setCellValue(gret15f); c121.setCellValue(less15m); c122.setCellValue(gret15m); c123.setCellValue(TotalTested); c124.setCellValue(TotalPositive); c125.setCellValue(TotalNegative); c126.setCellValue(TotalTested); c127.setCellValue("PASSED"); System.out.println(facilityname + " jjj " + AdultMaleHIV19Neg + "__________" + AdultMaleHIV24Neg + "__________" + AdultMaleHIV49Neg + "__________" + AdultMaleHIV50Neg + "__________" + ChildMaleHIV1Neg + "__________" + ChildMaleHIV4Neg + "__________" + ChildMaleHIV9Neg + "__________" + ChildMaleHIV14Neg); for (int i = 23; i <= 43; i++) { c11 = rw0.getCell(i); c11.setCellStyle(stborder); if (redalert2 == 1) { c11 = rw0.getCell(25); c11.setCellStyle(redstyle); } if (redalert3 == 1) { c110 = rw0.getCell(34); c110.setCellStyle(redstyle); } if (finalalert == 1) { c119 = rw0.getCell(43); c119.setCellStyle(redstyle); c119.setCellValue("FAILED"); } if (neg1female == 1) { c12 = rw0.getCell(26); c12.setCellStyle(redstyle); } if (neg4female == 1) { c12 = rw0.getCell(27); c12.setCellStyle(redstyle); } if (neg9female == 1) { c13 = rw0.getCell(28); c13.setCellStyle(redstyle); } if (neg14female == 1) { c14 = rw0.getCell(29); c14.setCellStyle(redstyle); } if (neg19female == 1) { c15 = rw0.getCell(30); c15.setCellStyle(redstyle); } if (neg24female == 1) { c16 = rw0.getCell(31); c16.setCellStyle(redstyle); } if (neg49female == 1) { c17 = rw0.getCell(32); c17.setCellStyle(redstyle); } if (neg50female == 1) { c18 = rw0.getCell(33); c18.setCellStyle(redstyle); } //male if (neg1male == 1) { c111 = rw0.getCell(35); c111.setCellStyle(redstyle); } if (neg4male == 1) { c112 = rw0.getCell(36); c112.setCellStyle(redstyle); } if (neg9male == 1) { c113 = rw0.getCell(37); c113.setCellStyle(redstyle); } if (neg14male == 1) { c114 = rw0.getCell(38); c114.setCellStyle(redstyle); } if (neg19male == 1) { c115 = rw0.getCell(39); c115.setCellStyle(redstyle); } if (neg24male == 1) { c116 = rw0.getCell(40); c116.setCellStyle(redstyle); } if (neg49male == 1) { c117 = rw0.getCell(41); c117.setCellStyle(redstyle); } if (neg50male == 1) { c118 = rw0.getCell(42); c118.setCellStyle(redstyle); } } // shet3.addMergedRegion(new CellRangeAddress(2,5,20,20)); } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //==============================================================================================VMMC //______________ HSSFWorkbook wb=new HSSFWorkbook();__________________________________________ //_________________________________________________________________________________________________ //_________________________________________________________________________________________________ //_________________________________________________________________________________________________ //================================================================================================== if (1 == 1) { //get the existing data for the month, year and facility that is already on session String month = ""; String year = ""; String facil = "361"; String form = "vmmc"; //===================================================================================================== year = "2015"; month = "5"; String county = ""; String header = ""; String reportType = ""; if (request.getParameter("reportType") != null) { reportType = request.getParameter("reportType"); } String reportDuration = ""; if (request.getParameter("reportDuration") != null) { reportDuration = request.getParameter("reportDuration"); } if (request.getParameter("year") != null) { year = request.getParameter("year"); } if (request.getParameter("facility") != null && reportType.equals("2")) { facil = request.getParameter("facility"); String getfacil = "select SubPartnerNom,CentreSanteId as mflcode from " + facilitiestable + " where SubPartnerID='" + facil + "'"; conn.rs = conn.st.executeQuery(getfacil); while (conn.rs.next()) { header += " FACILITY : " + conn.rs.getString(1).toUpperCase() + " MFL CODE : " + conn.rs.getString(2) + " "; } } if (request.getParameter("county") != null && reportType.equals("2")) { county = request.getParameter("county"); String getcounty = "select County from county where CountyID='" + county + "'"; conn.rs = conn.st.executeQuery(getcounty); while (conn.rs.next()) { header += " COUNTY : " + conn.rs.getString(1).toUpperCase() + " "; } } if (request.getParameter("month") != null && reportDuration.equals("4")) { month = request.getParameter("month"); String getmonth = "select name as monthname from month where id='" + month + "'"; conn.rs = conn.st.executeQuery(getmonth); while (conn.rs.next()) { header += " MONTH : " + conn.rs.getString(1).toUpperCase() + ""; } } header += " YEAR : " + year + ""; String facilitywhere = ""; String yearwhere = ""; String monthwhere = ""; String countywhere = ""; String duration = ""; String semi_annual = ""; String quarter = ""; //================================================================================================== //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX int yearcopy = Integer.parseInt(year); // reportType="2"; // year=2015; // reportDuration="3"; String yearmonth = "" + year; int prevYear = yearcopy - 1; int maxYearMonth = 0; int monthcopy = 0; // GET REPORT DURATION============================================ if (reportDuration.equals("1")) { yearmonth = "Annual Report For " + year; duration = " " + form + ".yearmonth BETWEEN " + prevYear + "10 AND " + year + "09"; } else if (reportDuration.equals("2")) { semi_annual = request.getParameter("semi_annual"); // semi_annual="2"; if (semi_annual.equals("1")) { yearmonth = "Semi Annual Report For " + prevYear + " Oct to " + year + " Mar"; duration = " " + form + ".yearmonth BETWEEN " + prevYear + "10 AND " + year + "03"; } else { yearmonth = "Semi Annual Report for Apr to Sep " + year; duration = " " + form + ".yearmonth BETWEEN " + year + "04 AND " + year + "09"; } } else if (reportDuration.equals("3")) { String startMonth, endMonth; quarter = request.getParameter("quarter"); // quarter="3"; String getMonths = "SELECT months,name FROM quarter WHERE id='" + quarter + "'"; conn.rs = conn.st.executeQuery(getMonths); if (conn.rs.next() == true) { String months[] = conn.rs.getString(1).split(","); startMonth = months[0]; endMonth = months[2]; if (quarter.equals("1")) { duration = " " + form + ".yearmonth BETWEEN " + prevYear + "" + startMonth + " AND " + prevYear + "" + endMonth; yearmonth = "Quarterly Report For " + prevYear + " " + conn.rs.getString(2); } else { yearmonth = "Quarterly Report For " + year + " (" + conn.rs.getString(2) + ")"; duration = " " + form + ".yearmonth BETWEEN " + year + "" + startMonth + " AND " + year + "" + endMonth; } } } else if (reportDuration.equals("4")) { monthcopy = Integer.parseInt(request.getParameter("month")); // month=5; if (monthcopy >= 10) { yearmonth = "Monthly Report For " + prevYear + "_(" + month + ")"; duration = " " + form + ".yearmonth=" + prevYear + "" + month; } else { duration = " " + form + ".yearmonth=" + year + "0" + month; yearmonth = "Monthly Report For " + year + "_(" + month + ")"; } } else { duration = ""; } //====================================================================== //================================================================================================== //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX String subcountywhere = ""; String subcounty = ""; if (!request.getParameter("subcounty").equals("")) { subcounty = request.getParameter("subcounty"); } String getexistingdata = ""; if (!county.equals("")) { countywhere = " and district.countyid = '" + county + "'"; } if (!subcounty.equals("")) { subcountywhere = " and " + facilitiestable + ".DistrictID = '" + subcounty + "'"; } if (!facil.equals("")) { facilitywhere = " and " + form + ".SubPartnerID = '" + facil + "'"; } String joinedwhwere = " where 1=1 " + yearwhere + " && " + duration + " " + countywhere + " " + subcountywhere; //===================================================================================================== //FINDFACILITIES //===================================================================================================== //______________________________________________________________________________________ // NOW CREATE THE WORKSHEETS //______________________________________________________________________________________ //______________________________________________________________________________________ //______________________________________________________________________________________ HSSFFont font = wb.createFont(); font.setFontHeightInPoints((short) 18); font.setFontName("Cambria"); font.setColor((short) 0000); CellStyle style = wb.createCellStyle(); style.setFont(font); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFFont font2 = wb.createFont(); font2.setFontName("Cambria"); font2.setColor((short) 0000); CellStyle style2 = wb.createCellStyle(); style2.setFont(font2); style2.setBorderTop(HSSFCellStyle.BORDER_THIN); style2.setBorderBottom(HSSFCellStyle.BORDER_THIN); style2.setBorderLeft(HSSFCellStyle.BORDER_THIN); style2.setBorderRight(HSSFCellStyle.BORDER_THIN); style2.setAlignment(HSSFCellStyle.ALIGN_LEFT); style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); HSSFCellStyle stborder = wb.createCellStyle(); stborder.setBorderTop(HSSFCellStyle.BORDER_THIN); stborder.setBorderBottom(HSSFCellStyle.BORDER_THIN); stborder.setBorderLeft(HSSFCellStyle.BORDER_THIN); stborder.setBorderRight(HSSFCellStyle.BORDER_THIN); stborder.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFCellStyle stylex = wb.createCellStyle(); stylex.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); stylex.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); stylex.setBorderTop(HSSFCellStyle.BORDER_THIN); stylex.setBorderBottom(HSSFCellStyle.BORDER_THIN); stylex.setBorderLeft(HSSFCellStyle.BORDER_THIN); stylex.setBorderRight(HSSFCellStyle.BORDER_THIN); stylex.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFFont fontx = wb.createFont(); fontx.setColor(HSSFColor.BLACK.index); fontx.setFontName("Cambria"); fontx.setBoldweight(Font.BOLDWEIGHT_BOLD); stylex.setFont(fontx); stylex.setWrapText(true); HSSFSheet shet = wb.createSheet(form.toUpperCase()); //create headers for that worksheet HSSFRow rw = shet.createRow(0); rw.setHeightInPoints(25); HSSFCell cl0 = rw.createCell(0); cl0.setCellValue("DATIM " + yearmonth); cl0.setCellStyle(stylex); for (int a = 1; a <= 13; a++) { HSSFCell clx = rw.createCell(a); clx.setCellValue(""); clx.setCellStyle(stylex); } HSSFRow rw1 = shet.createRow(1); rw1.setHeightInPoints(23); HSSFCell cl = rw1.createCell(0); cl.setCellValue(""); cl.setCellStyle(style2); for (int a = 1; a <= 13; a++) { HSSFCell clx = rw1.createCell(a); clx.setCellValue(""); clx.setCellStyle(style2); } HSSFRow rw2 = shet.createRow(2); rw2.setHeightInPoints(23); HSSFCell cl3 = rw2.createCell(0); cl3.setCellValue("VMMC CIRC "); cl3.setCellStyle(stylex); HSSFCell cl31 = rw2.createCell(1); cl31.setCellValue(""); cl31.setCellStyle(stylex); for (int a = 2; a <= 5; a++) { HSSFCell clx = rw2.createCell(a); clx.setCellValue(""); clx.setCellStyle(stylex); } HSSFCell cl3b = rw2.createCell(6); cl3b.setCellValue("Disaggregated by Age "); cl3b.setCellStyle(stylex); for (int a = 7; a <= 13; a++) { HSSFCell clx = rw2.createCell(a); clx.setCellValue(""); clx.setCellStyle(stylex); } HSSFCell cl3c = rw2.createCell(14); cl3c.setCellValue("Disaggregated by HIV Status "); cl3c.setCellStyle(stylex); for (int a = 15; a <= 16; a++) { HSSFCell clx = rw2.createCell(a); clx.setCellValue(""); clx.setCellStyle(stylex); } HSSFCell cl3d = rw2.createCell(17); cl3d.setCellValue("Disaggregated by Circumcission Technique "); cl3d.setCellStyle(stylex); HSSFCell cl3e = rw2.createCell(18); cl3e.setCellValue("Disaggregated by Followup (For surgical only) "); cl3e.setCellStyle(stylex); for (int a = 19; a < 20; a++) { HSSFCell clx = rw2.createCell(a); clx.setCellValue(""); clx.setCellStyle(stylex); } HSSFCell cl3f = rw2.createCell(20); cl3f.setCellValue("VMMC_AE Disaggregated by AE Type"); cl3f.setCellStyle(stylex); for (int a = 21; a < 27; a++) { HSSFCell clx = rw2.createCell(a); clx.setCellValue(""); clx.setCellStyle(stylex); } // String VMMCheaders[] = { "County", "Sub-County", "Facility Name", "Mfl Code", "Type Of Support", "Numerator", "< 1", "1-9", "10-14", "15-19", "20-24", "25-29", "30-49", "50+", "HIV-positive clients (tested HIV positive at VMMC site", "HIV-negative clients (tested HIV negative at VMMC program", "Unknown HIV status/not tested for HIV on site/indeterminate HIV status/undocumented HIV status", "Device-Based", "Number of surgical VMMC clients who returned at least once for follow-up care within 14 days of surgery", "Number of surgical VMMC clients who did not return for follow-up care within 14 days of surgery", "Numerator", "Surgical Intra- operative: Moderate", "Surgical Intra- operative: Severe", "Surgical Post- operative: Moderate", "Surgical Post- operative: Severe", "Medical Device-related: Moderate", "Medical Device-related: Severe" }; HSSFRow rw3 = shet.createRow(3); rw3.setHeightInPoints(63); for (int a = 0; a < VMMCheaders.length; a++) { HSSFCell clx = rw3.createCell(a); clx.setCellValue(VMMCheaders[a]); clx.setCellStyle(stylex); } //shet.addMergedRegion(new CellRangeAddress(2,10,0,0)); shet.addMergedRegion(new CellRangeAddress(0, 0, 0, 13)); shet.addMergedRegion(new CellRangeAddress(1, 1, 0, 13)); //shet.addMergedRegion(new CellRangeAddress(1,1,0,4)); shet.addMergedRegion(new CellRangeAddress(2, 2, 1, 5)); shet.addMergedRegion(new CellRangeAddress(2, 2, 6, 13)); shet.addMergedRegion(new CellRangeAddress(2, 2, 14, 16)); shet.addMergedRegion(new CellRangeAddress(2, 2, 18, 19)); shet.addMergedRegion(new CellRangeAddress(2, 2, 20, 26)); shet.setColumnWidth(0, 5000); shet.setColumnWidth(1, 5000); shet.setColumnWidth(2, 6000); shet.setColumnWidth(3, 6000); shet.setColumnWidth(4, 6000); shet.setColumnWidth(5, 2500); shet.setColumnWidth(14, 6500); shet.setColumnWidth(15, 6500); shet.setColumnWidth(16, 6500); shet.setColumnWidth(17, 6500); shet.setColumnWidth(18, 6500); shet.setColumnWidth(19, 6500); shet.setColumnWidth(20, 3000); shet.setColumnWidth(21, 6000); shet.setColumnWidth(22, 6000); shet.setColumnWidth(23, 6000); shet.setColumnWidth(24, 6000); shet.setColumnWidth(25, 6000); shet.setColumnWidth(26, 6000); //BEFORE WHILE LOOP //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ArrayList staticfacility = new ArrayList(); ArrayList staticcounty = new ArrayList(); ArrayList staticdistrict = new ArrayList(); ArrayList staticmfl = new ArrayList(); ArrayList staticdsd_ta = new ArrayList(); int blankrows = 27; String getstaticfacilities = "SELECT county.County as county,district.DistrictNom as district," // + " " + facilitiestable + ".SubPartnerNom as facility, " + facilitiestable + ".CentreSanteId as mflcode, " + facilitiestable + ".HTC_Support1 as htcsupport " + " FROM " + facilitiestable + " join (district join county on county.CountyID=district.CountyID) on district.DistrictID = " + facilitiestable + ".DistrictID where ( VMMC='1') group by " + facilitiestable + ".SubPartnerID "; conn.rs = conn.st.executeQuery(getstaticfacilities); while (conn.rs.next()) { staticcounty.add(conn.rs.getString("county")); String district = conn.rs.getString("district"); staticdistrict .add(district.substring(0, 1).toUpperCase() + district.substring(1).toLowerCase()); staticfacility.add(conn.rs.getString("facility")); staticmfl.add(conn.rs.getString("mflcode")); //dsdta=conn.rs.getString("htcsupport"); String dsdta = "DSD"; //static as of 201606 staticdsd_ta.add(dsdta); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //getexistingdata="select county,DistrictNom, SubPartnerNom, CentreSanteId as mflcode , sum(P51DT) as P51DT, sum(P51D1) as P51D1, sum(P51D9) as P51D9, sum(P51D10) as P51D10, sum(P51D19) as P51D19,sum(P51D24) as P51D24, sum(P51D29) as P51D29, sum(P51D49) as P51D49, sum(P51D50) as P51D50, sum(P51DT) as P51DT, sum(P521DM) as P521DM, sum(P521DS) as P521DS, sum(P521DT) as P521DT, sum(P522DM) as P522DM, sum(P522DS) as P522DS, sum(P522DT) as P522DT, sum(P52DM) as P52DM, sum(P52DS) as P52DS, sum(P52DT) as P52DT, sum(P511KP) as P511KP, sum(P511KN) as P511KN, sum(P511KU) as P511KU, sum(P511Surg) as P511Surg, sum(P511Dev) as P511Dev, sum(P53DF) as P53DF, sum(P53DO) as P53DO, sum(P53DM) as P53DM, sum(P53D) as P53D, sum(P54D) as P54D from "+form+" join ( subpartnera join (district join county on county.CountyID=district.CountyID ) on district.DistrictID = subpartnera.DistrictID ) on "+form+".SubPartnerID = subpartnera.SubPartnerID "+joinedwhwere+" group by subpartnera.SubPartnerID "; getexistingdata = "select county,DistrictNom, SubPartnerNom, CentreSanteId as mflcode , sum(P51DT) as P51DT, sum(P51D1) as P51D1, sum(P51D9) as P51D9, sum(P51D10) as P51D10, sum(P51D19) as P51D19,sum(P51D24) as P51D24, sum(P51D29) as P51D29, sum(P51D49) as P51D49, sum(P51D50) as P51D50, sum(P511KP) as P511KP , sum(P511KN) as P511KN, sum(P511KU) as P511KU , sum(P511Dev) as P511Dev , sum(P54D) as P54D , sum(P511Surg) as P511Surg , sum(P521DM + P521DS + P522DM + P522DS) as aenumerator , sum(P521DM) as P521DM , sum(P521DS) as P521DS , sum(P522DM) as P522DM , sum(P522DS) as P522DS from " + form + " join ( " + facilitiestable + " join (district join county on county.CountyID=district.CountyID ) on district.DistrictID = " + facilitiestable + ".DistrictID ) on " + form + ".SubPartnerID = " + facilitiestable + ".SubPartnerID " + joinedwhwere + " group by " + facilitiestable + ".SubPartnerID "; System.out.println(getexistingdata); String P51D1 = ""; String P51D9 = ""; String P51D10 = ""; String P51D19 = ""; String P51D24 = ""; String P51D29 = ""; String P51D49 = ""; String P51D50 = ""; String P51DT = ""; String P511KP = ""; String P521DM = ""; String P521DS = ""; // String P521DT = ""; String P522DM = ""; String P522DS = ""; // String P522DT = ""; // String P52DM = ""; // String P52DS = ""; // String P52DT = ""; // String P511KP = ""; String P511KN = ""; String P511KU = ""; String P511Surg = ""; String P511Dev = ""; // String P53DF = ""; // String P53DO = ""; // String P53DM = ""; // String P53D = ""; String P54D = ""; String distid = ""; int counter = 0; conn.rs = conn.st.executeQuery(getexistingdata); int r = 4; while (conn.rs.next()) { //INSIDE WHILE LOOP //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //REMOVE SITES THAT HAVE DATA FROM THE STATIC ARRAYLIST SET //get the index of the current facility int mflindex = staticmfl.indexOf(conn.rs.getString("mflcode")); if (mflindex != -1) { //remove the element from the arraylist staticfacility.remove(mflindex); staticcounty.remove(mflindex); staticdistrict.remove(mflindex); staticmfl.remove(mflindex); staticdsd_ta.remove(mflindex); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //now check if form was updated and if its one month after data entry //now load the column values here P51D1 = conn.rs.getString("P51D1"); if (P51D1 == null) { P51D1 = ""; } P51D9 = conn.rs.getString("P51D9"); if (P51D9 == null) { P51D9 = ""; } P51D10 = conn.rs.getString("P51D10"); if (P51D10 == null) { P51D10 = ""; } P51D19 = conn.rs.getString("P51D19"); if (P51D19 == null) { P51D19 = ""; } P51D24 = conn.rs.getString("P51D24"); if (P51D24 == null) { P51D24 = ""; } P51D29 = conn.rs.getString("P51D29"); if (P51D29 == null) { P51D29 = ""; } P51D49 = conn.rs.getString("P51D49"); if (P51D49 == null) { P51D49 = ""; } P51D50 = conn.rs.getString("P51D50"); if (P51D50 == null) { P51D50 = ""; } P51DT = conn.rs.getString("P51DT"); if (P51DT == null) { P51DT = ""; } P521DM = conn.rs.getString("P521DM"); if (P521DM == null) { P521DM = ""; } // P521DS = conn.rs.getString("P521DS"); if (P521DS == null) { P521DS = ""; } // // P521DT = conn.rs.getString("P521DT"); // if (P521DT == null) { // P521DT = ""; // } // // // P522DM = conn.rs.getString("P522DM"); if (P522DM == null) { P522DM = ""; } // P522DS = conn.rs.getString("P522DS"); if (P522DS == null) { P522DS = ""; } // // P522DT = conn.rs.getString("P522DT"); // if (P522DT == null) { // P522DT = ""; // } // // // P52DM = conn.rs.getString("P52DM"); // if (P52DM == null) { // P52DM = ""; // } // // // P52DS = conn.rs.getString("P52DS"); // if (P52DS == null) { // P52DS = ""; // } // // // P52DT = conn.rs.getString("P52DT"); // if (P52DT == null) { // P52DT = ""; // } // // P511KP = conn.rs.getString("P511KP"); if (P511KP == null) { P511KP = ""; } // // P511KN = conn.rs.getString("P511KN"); if (P511KN == null) { P511KN = ""; } P511KU = conn.rs.getString("P511KU"); if (P511KU == null) { P511KU = ""; } // P511Surg = conn.rs.getString("P511Surg"); if (P511Surg == null) { P511Surg = ""; } // // P511Dev = conn.rs.getString("P511Dev"); if (P511Dev == null) { P511Dev = ""; } // // P53DF = conn.rs.getString("P53DF"); // if (P53DF == null) { // P53DF = ""; // } // // P53DO = conn.rs.getString("P53DO"); // if (P53DO == null) { // P53DO = ""; // } // // P53DM = conn.rs.getString("P53DM"); // if (P53DM == null) { // P53DM = ""; // } // // P53D = conn.rs.getString("P53D"); // if (P53D == null) { // P53D = ""; // } // P54D = conn.rs.getString("P54D"); if (P54D == null) { P54D = ""; } if (1 == 1) { if (1 == 1) { int celpos = 0; int celpos1 = 1; HSSFRow rwx = shet.createRow(r); rwx.setHeightInPoints(23); //County HSSFCell clx0 = rwx.createCell(celpos); clx0.setCellValue(conn.rs.getString(celpos1)); clx0.setCellStyle(style2); celpos++; celpos1++; //SubCounty HSSFCell clx = rwx.createCell(celpos); clx.setCellValue(conn.rs.getString(celpos1).substring(0, 1).toUpperCase() + conn.rs.getString(celpos1).substring(1).toLowerCase()); clx.setCellStyle(style2); celpos++; celpos1++; //Facility Name if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getString(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //Mfl Code if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getString(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //DSD/TA //im assuming that VMMC is made of DSDs as indicated in the Datim PDF screen shared by Supervisor if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue("DSD"); clx1.setCellStyle(style2); celpos++; } //Numerator if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //<1 if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //1-9 if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //10-24 if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //15-19 if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //20-24 if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //25-29 if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //30-49 if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //50+ if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //tested positive clients P511KP if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //tested negative clients P511KN if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //unknown untested P511KU if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //============================================================= //device based P511KU if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //============================================================= //Returned if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } if (1 == 1) { int notreturned = 0; if (conn.rs.getInt("P51DT") - conn.rs.getInt("P54D") > 0) { //here im subtracting surgical vmmc and males who returned for postoperative follow notreturned = conn.rs.getInt("P51DT") - conn.rs.getInt("P54D"); } HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(notreturned); clx1.setCellStyle(style2); //increment to get past P511Surg celpos++; celpos1++; } //============================================================= //VMMC_AE Numerator if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //intra-operative moderate if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //intra-operative severe if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } // surgicalpost-operative moderate if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } // surgicalpost-operative severe if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(conn.rs.getInt(celpos1)); clx1.setCellStyle(style2); celpos++; celpos1++; } //Medical device related Moderate if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(""); clx1.setCellStyle(style2); celpos++; celpos1++; } //Medical device related Severe if (1 == 1) { HSSFCell clx1 = rwx.createCell(celpos); clx1.setCellValue(""); clx1.setCellStyle(style2); celpos++; celpos1++; } r++; } //===================================================================================== } //end of if 1==1 } //end of while loop //System.out.println(createdtable); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HSSFRow rwx = null; for (int a = 0; a < staticfacility.size(); a++) { //outer loop taking care of the no of rows rwx = shet.createRow(r); rwx.setHeightInPoints(23); r++; for (int z = 0; z < blankrows; z++) { //inner loop taking care of the number of columns //create a row if (z == 0) { //county HSSFCell cellcounty = rwx.createCell(0); cellcounty.setCellValue(staticcounty.get(a).toString()); cellcounty.setCellStyle(style2); } else if (z == 1) { //sub-county HSSFCell cellsubcounty = rwx.createCell(1); cellsubcounty.setCellValue(staticdistrict.get(a).toString()); cellsubcounty.setCellStyle(style2); } else if (z == 2) { //facility HSSFCell cellfacil = rwx.createCell(2); cellfacil.setCellValue(staticfacility.get(a).toString()); cellfacil.setCellStyle(style2); } else if (z == 3) { //mfl HSSFCell cellmfl = rwx.createCell(3); cellmfl.setCellValue(staticmfl.get(a).toString()); cellmfl.setCellStyle(style2); } else if (z == 4) { //dsdta HSSFCell celldsd = rwx.createCell(4); celldsd.setCellValue(staticdsd_ta.get(a).toString()); celldsd.setCellStyle(style2); } else if (z == blankrows - 1) { //dsdta HSSFCell celldsd = rwx.createCell(blankrows - 1); celldsd.setCellValue(0); celldsd.setCellStyle(style2); } else { HSSFCell celldata = rwx.createCell(z); celldata.setCellValue(0); celldata.setCellStyle(style2); } //end of else } //end of inner loop } //end of outer loop //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } //================================================================================================== //HTC RESULTS BY SDP //================================================================================================== if (1 == 1) { String month = ""; String year = ""; String facil = "361"; String form = "moh711"; //===================================================================================================== year = "2015"; month = "5"; String county = ""; String header = ""; String subheaders[] = { "Tested", "Positive", "Negative" }; String sectionheaders[] = { "County", "Sub-county", "Health Facility", "Mfl Code", "Type Of Support", "ART High Volume", "HTC High Volume", "PMTCT High Volume", "Antenatal Clinic", "", "", "Labour & Delivery", "", "", "Under 5 Clinic", "", "", "Postnatal", "", "", "Tuberculosis", "", "", "Outpatient Department", "", "", "Inpatient", "", "", "Voluntary Medical Male Circumcission", "", "", "Voluntary Counselling & Testing (Co-located)", "", "" }; //String sectionheaders[]={"County","Sub-county","Health Facility","Mfl Code","Type Of Support","Antenatal Clinic","","","Labour & Delivery","","","Under 5 Clinic","","","Postnatal","","","TB_STAT","","","Sexually Transmitted Infections","","","Outpatient Department","","","Inpatient","","","Hiv Care and Treatment Clinic","","","Voluntary Medical Male Circumcission","","","Voluntary Counselling & Testing (Co-located)","","","Voluntary Counselling & Testing (Standalone)","","","Mobile","","","Home-based","","","Other","",""}; String reportType = ""; if (request.getParameter("reportType") != null) { reportType = request.getParameter("reportType"); } String reportDuration = ""; if (request.getParameter("reportDuration") != null) { reportDuration = request.getParameter("reportDuration"); } if (request.getParameter("year") != null) { year = request.getParameter("year"); } if (request.getParameter("facility") != null && reportType.equals("2")) { try { facil = request.getParameter("facility"); String getfacil = "select SubPartnerNom,CentreSanteId as mflcode from " + facilitiestable + " where SubPartnerID='" + facil + "'"; conn.rs = conn.st.executeQuery(getfacil); while (conn.rs.next()) { header += " FACILITY : " + conn.rs.getString(1).toUpperCase() + " MFL CODE : " + conn.rs.getString(2) + " "; } } catch (SQLException ex) { Logger.getLogger(datimHTCResults.class.getName()).log(Level.SEVERE, null, ex); } } if (request.getParameter("county") != null && reportType.equals("2")) { try { county = request.getParameter("county"); String getcounty = "select County from county where CountyID='" + county + "'"; conn.rs = conn.st.executeQuery(getcounty); while (conn.rs.next()) { header += " COUNTY : " + conn.rs.getString(1).toUpperCase() + " "; } } catch (SQLException ex) { Logger.getLogger(datimHTCResults.class.getName()).log(Level.SEVERE, null, ex); } } if (request.getParameter("month") != null && reportDuration.equals("4")) { try { month = request.getParameter("month"); String getmonth = "select name as monthname from month where id='" + month + "'"; conn.rs = conn.st.executeQuery(getmonth); while (conn.rs.next()) { header += " MONTH : " + conn.rs.getString(1).toUpperCase() + ""; } } catch (SQLException ex) { Logger.getLogger(datimHTCResults.class.getName()).log(Level.SEVERE, null, ex); } } header += " YEAR : " + year + ""; String facilitywhere = ""; String yearwhere = ""; String monthwhere = ""; String countywhere = ""; String duration = ""; String semi_annual = ""; String quarter = ""; String tbstatduration = ""; //================================================================================================== //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX int yearcopy = Integer.parseInt(year); // reportType="2"; // year=2015; // reportDuration="3"; String yearmonth = "" + year; int prevYear = yearcopy - 1; int maxYearMonth = 0; int monthcopy = 0; // GET REPORT DURATION============================================ //annually if (reportDuration.equals("1")) { yearmonth = "Annual Report For " + year; duration = " " + form + ".yearmonth BETWEEN " + prevYear + "10 AND " + year + "09"; tbstatduration = "year='" + year + "'"; } else if (reportDuration.equals("2")) { semi_annual = request.getParameter("semi_annual"); // semi_annual="2"; if (semi_annual.equals("1")) { yearmonth = "Semi Annual Report For " + prevYear + " Oct to " + year + " Mar"; duration = " " + form + ".yearmonth BETWEEN " + prevYear + "10 AND " + year + "03"; tbstatduration = "year='" + year + "' and (quarter='1' || quarter='2') "; } else { yearmonth = "Semi Annual Report for Apr to Sep " + year; duration = " " + form + ".yearmonth BETWEEN " + year + "04 AND " + year + "09"; tbstatduration = "year='" + year + "' and (quarter='2' || quarter='3') "; } } else if (reportDuration.equals("3")) { try { //quarterly String startMonth, endMonth; quarter = request.getParameter("quarter"); // quarter="3"; tbstatduration = "year='" + year + "' and quarter='" + quarter + "' "; String getMonths = "SELECT months,name FROM quarter WHERE id='" + quarter + "'"; conn.rs = conn.st.executeQuery(getMonths); if (conn.rs.next() == true) { try { String months[] = conn.rs.getString(1).split(","); startMonth = months[0]; endMonth = months[2]; if (quarter.equals("1")) { duration = " " + form + ".yearmonth BETWEEN " + prevYear + "" + startMonth + " AND " + prevYear + "" + endMonth; yearmonth = "Quarterly Report For " + prevYear + " " + conn.rs.getString(2); } else { yearmonth = "Quarterly Report For " + year + " (" + conn.rs.getString(2) + ")"; duration = " " + form + ".yearmonth BETWEEN " + year + "" + startMonth + " AND " + year + "" + endMonth; } } catch (SQLException ex) { Logger.getLogger(datimHTCResults.class.getName()).log(Level.SEVERE, null, ex); } } } catch (SQLException ex) { Logger.getLogger(datimHTCResults.class.getName()).log(Level.SEVERE, null, ex); } } else if (reportDuration.equals("4")) { monthcopy = Integer.parseInt(request.getParameter("month")); //since we dont want data to appear for monthly reports, we set an impossible tbstatduration = " 1=2 "; // month=5; if (monthcopy >= 10) { yearmonth = "Monthly Report For " + prevYear + "_(" + month + ")"; duration = " " + form + ".yearmonth=" + prevYear + "" + month; } else { duration = " " + form + ".yearmonth=" + year + "0" + month; yearmonth = "Monthly Report For " + year + "_(" + month + ")"; } } else { duration = ""; } //====================================================================== //================================================================================================== //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX String subcountywhere = ""; String subcounty = ""; if (!request.getParameter("subcounty").equals("")) { subcounty = request.getParameter("subcounty"); } String getexistingdata = ""; if (!county.equals("")) { countywhere = " and district.countyid = '" + county + "'"; } if (!subcounty.equals("")) { subcountywhere = " and " + facilitiestable + ".DistrictID = '" + subcounty + "'"; } if (!facil.equals("") && reportType.equalsIgnoreCase("2")) { facilitywhere = " and " + form + ".SubPartnerID = '" + facil + "'"; } String joinedwhwere = " where 1=1 " + yearwhere + " && " + duration + " " + countywhere + " " + subcountywhere; //BEFORE WHILE LOOP //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ArrayList staticfacility = new ArrayList(); ArrayList staticcounty = new ArrayList(); ArrayList staticdistrict = new ArrayList(); ArrayList staticmfl = new ArrayList(); ArrayList staticdsd_ta = new ArrayList(); ArrayList staticart_hv = new ArrayList(); ArrayList statichtc_hv = new ArrayList(); ArrayList staticpmtct_hv = new ArrayList(); int blankrows = 35; String getstaticfacilities = "SELECT county.County as county,district.DistrictNom as district," // + " " + facilitiestable + ".SubPartnerNom as facility, " + facilitiestable + ".CentreSanteId as mflcode, " + facilitiestable + ".HTC_Support1 as htcsupport,ART_highvolume, HTC_highvolume,PMTCT_highvolume " + " FROM " + facilitiestable + " join (district join county on county.CountyID=district.CountyID ) on district.DistrictID = " + facilitiestable + ".DistrictID where (HTC='1'||PMTCT='1'||VMMC='1') group by " + facilitiestable + ".SubPartnerID "; conn.rs = conn.st.executeQuery(getstaticfacilities); while (conn.rs.next()) { staticcounty.add(conn.rs.getString("county")); String district = conn.rs.getString("district"); staticdistrict .add(district.substring(0, 1).toUpperCase() + district.substring(1).toLowerCase()); staticfacility.add(conn.rs.getString("facility")); staticmfl.add(conn.rs.getString("mflcode")); //dsdta=conn.rs.getString("htcsupport"); String dsdta = "DSD"; //static as of 201606 staticdsd_ta.add(dsdta); if (conn.rs.getString("ART_highvolume") != null) { staticart_hv.add(conn.rs.getString("ART_highvolume")); } else { staticart_hv.add(""); } if (conn.rs.getString("HTC_highvolume") != null) { statichtc_hv.add(conn.rs.getString("HTC_highvolume")); } else { statichtc_hv.add(""); } if (conn.rs.getString("PMTCT_highvolume") != null) { staticpmtct_hv.add(conn.rs.getString("PMTCT_highvolume")); } else { staticpmtct_hv.add(""); } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //getexistingdata="select county,DistrictNom, SubPartnerNom, CentreSanteId as mflcode ,HTC_Support1,PMTCT_Support, sum(HV0201) as HV0201,sum(HV0202) as HV0202,sum(HV0203) as HV0203,sum(HV0206) as HV0206,sum(HV0207) as HV0207,sum(HV0208) as HV0208,sum(HV0228) as HV0228,sum(HV0232) as HV0232, sum(DTCB_Test_Out_Tot) as DTCB_Test_Out_Tot,sum(DTCB_Test_In_Tot) as DTCB_Test_In_Tot , sum(DTCC_HIV_Out_Tot) as DTCC_HIV_Out_Tot, sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN, subpartnera.SubPartnerID as SubPartnerID FROM moh711 left join moh731 on moh731.id=moh711.id left join vmmc on moh711.id=vmmc.tableid join ( subpartnera join (district join county on county.CountyID=district.CountyID ) on district.DistrictID = subpartnera.DistrictID ) on "+form+".SubPartnerID = subpartnera.SubPartnerID "+joinedwhwere+" and (HTC='1'||PMTCT='1'||VMMC='1') group by subpartnera.SubPartnerID order by county union select county,DistrictNom, SubPartnerNom, CentreSanteId as mflcode ,HTC_Support1,PMTCT_Support, sum(HV0201) as HV0201,sum(HV0202) as HV0202,sum(HV0203) as HV0203,sum(HV0206) as HV0206,sum(HV0207) as HV0207,sum(HV0208) as HV0208,sum(HV0228) as HV0228,sum(HV0232) as HV0232, sum(DTCB_Test_Out_Tot) as DTCB_Test_Out_Tot,sum(DTCB_Test_In_Tot) as DTCB_Test_In_Tot , sum(DTCC_HIV_Out_Tot) as DTCC_HIV_Out_Tot, sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN, subpartnera.SubPartnerID as SubPartnerID FROM moh711 right join moh731 on moh731.id=moh711.id right join vmmc on moh711.id=vmmc.tableid join ( subpartnera join (district join county on county.CountyID=district.CountyID ) on district.DistrictID = subpartnera.DistrictID ) on "+form+".SubPartnerID = subpartnera.SubPartnerID "+joinedwhwere+" and (HTC='1'||PMTCT='1'||VMMC='1') group by subpartnera.SubPartnerID order by county"; //getexistingdata="select county,DistrictNom, SubPartnerNom, CentreSanteId as mflcode ,HTC_Support1,PMTCT_Support, sum(HV0201) as HV0201,sum(HV0202) as HV0202,sum(HV0203) as HV0203,sum(HV0206) as HV0206,sum(HV0207) as HV0207,sum(HV0208) as HV0208,sum(HV0228) as HV0228,sum(HV0232) as HV0232, sum(DTCB_Test_Out_Tot) as DTCB_Test_Out_Tot,sum(DTCB_Test_In_Tot) as DTCB_Test_In_Tot , sum(DTCC_HIV_Out_Tot) as DTCC_HIV_Out_Tot, sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN, subpartnera.SubPartnerID as SubPartnerID FROM moh711 left join moh731 on moh731.id=moh711.id left join vmmc on moh711.id=vmmc.tableid join ( subpartnera join (district join county on county.CountyID=district.CountyID ) on district.DistrictID = subpartnera.DistrictID ) on "+form+".SubPartnerID = subpartnera.SubPartnerID "+joinedwhwere+" and (HTC='1'||PMTCT='1'||VMMC='1') group by subpartnera.SubPartnerID union select county,DistrictNom, SubPartnerNom, CentreSanteId as mflcode ,HTC_Support1,PMTCT_Support, sum(HV0201) as HV0201,sum(HV0202) as HV0202,sum(HV0203) as HV0203,sum(HV0206) as HV0206,sum(HV0207) as HV0207,sum(HV0208) as HV0208,sum(HV0228) as HV0228,sum(HV0232) as HV0232, sum(DTCB_Test_Out_Tot) as DTCB_Test_Out_Tot,sum(DTCB_Test_In_Tot) as DTCB_Test_In_Tot , sum(DTCC_HIV_Out_Tot) as DTCC_HIV_Out_Tot, sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN, subpartnera.SubPartnerID as SubPartnerID FROM moh711 right join moh731 on moh731.id=moh711.id right join vmmc on moh711.id=vmmc.tableid join ( subpartnera join (district join county on county.CountyID=district.CountyID ) on district.DistrictID = subpartnera.DistrictID ) on "+form+".SubPartnerID = subpartnera.SubPartnerID "+joinedwhwere+" and (HTC='1'||PMTCT='1'||VMMC='1') group by subpartnera.SubPartnerID order by county"; getexistingdata = "select county,DistrictNom, SubPartnerNom, CentreSanteId as mflcode ,HTC_Support1,PMTCT_Support, sum(HV0201) as HV0201,sum(HV0202) as HV0202,sum(HV0203) as HV0203,sum(HV0206) as HV0206,sum(HV0207) as HV0207,sum(HV0208) as HV0208,sum(HV0228) as HV0228,sum(HV0232) as HV0232, sum(DTCB_Test_Out_Tot) as DTCB_Test_Out_Tot,sum(DTCB_Test_In_Tot) as DTCB_Test_In_Tot , sum(DTCC_HIV_Out_Tot) as DTCC_HIV_Out_Tot, sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, (sum(P511KN) + sum(P511KU)) as P511KN, " + facilitiestable + ".SubPartnerID as SubPartnerID ,ART_highvolume, HTC_highvolume,PMTCT_highvolume FROM moh711 left join moh731 on moh731.id=moh711.id left join vmmc on moh711.id=vmmc.tableid join ( " + facilitiestable + " join (district join county on county.CountyID=district.CountyID ) on district.DistrictID = " + facilitiestable + ".DistrictID ) on " + form + ".SubPartnerID = " + facilitiestable + ".SubPartnerID " + joinedwhwere + " and (HTC='1'||PMTCT='1'||VMMC='1') group by " + facilitiestable + ".SubPartnerID "; System.out.println("@@" + getexistingdata); String Tbid = year + "_" + quarter + "_" + facil; // String getstat="select sum(positive) as positive ,sum(negative) as negative from tb_stat_art WHERE "+tbstatduration; String distincttbstatfacils = "select distinct(SubPartnerID) as partnerid from tb_stat_art WHERE " + tbstatduration; ArrayList tbstat = new ArrayList(); conn.rs1 = conn.st1.executeQuery(distincttbstatfacils); while (conn.rs1.next()) { tbstat.add(conn.rs1.getString(1)); } //===================================================================================================== //===================================================================================================== //______________________________________________________________________________________ // NOW CREATE THE WORKSHEETS //______________________________________________________________________________________ // HSSFWorkbook wb = new HSSFWorkbook(); //______________________________________________________________________________________ //______________________________________________________________________________________ HSSFFont font = wb.createFont(); font.setFontHeightInPoints((short) 12); font.setFontName("Cambria"); font.setColor((short) 0000); CellStyle style = wb.createCellStyle(); style.setFont(font); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setAlignment(HSSFCellStyle.ALIGN_LEFT); style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); HSSFFont font2 = wb.createFont(); font2.setFontName("Cambria"); font2.setColor((short) 0000); CellStyle style2 = wb.createCellStyle(); style2.setFont(font2); style2.setBorderTop(HSSFCellStyle.BORDER_THIN); style2.setBorderBottom(HSSFCellStyle.BORDER_THIN); style2.setBorderLeft(HSSFCellStyle.BORDER_THIN); style2.setBorderRight(HSSFCellStyle.BORDER_THIN); style2.setAlignment(HSSFCellStyle.ALIGN_LEFT); style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); HSSFCellStyle stborder = wb.createCellStyle(); stborder.setBorderTop(HSSFCellStyle.BORDER_THIN); stborder.setBorderBottom(HSSFCellStyle.BORDER_THIN); stborder.setBorderLeft(HSSFCellStyle.BORDER_THIN); stborder.setBorderRight(HSSFCellStyle.BORDER_THIN); stborder.setAlignment(HSSFCellStyle.ALIGN_CENTER); //this font will be used to show errors on negatives HSSFCellStyle errorstyle = wb.createCellStyle(); errorstyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); errorstyle.setFillBackgroundColor(HSSFColor.RED.index); errorstyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); errorstyle.setBorderTop(HSSFCellStyle.BORDER_THIN); errorstyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); errorstyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); errorstyle.setBorderRight(HSSFCellStyle.BORDER_THIN); errorstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFCellStyle stylex = wb.createCellStyle(); stylex.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); stylex.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); stylex.setBorderTop(HSSFCellStyle.BORDER_THIN); stylex.setBorderBottom(HSSFCellStyle.BORDER_THIN); stylex.setBorderLeft(HSSFCellStyle.BORDER_THIN); stylex.setBorderRight(HSSFCellStyle.BORDER_THIN); stylex.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFFont fontx = wb.createFont(); fontx.setColor(HSSFColor.BLACK.index); fontx.setFontName("Cambria"); fontx.setBoldweight(Font.BOLDWEIGHT_BOLD); stylex.setFont(fontx); stylex.setWrapText(true); HSSFSheet shet = wb.createSheet("HTC RESULTS BY SDP"); int rowpos = 0; //create headers for that worksheet HSSFRow rw = shet.createRow(rowpos); rw.setHeightInPoints(25); HSSFCell cl0 = rw.createCell(0); cl0.setCellValue("HTC Results BY Service Delivery Point and Test Result(Required) " + yearmonth); cl0.setCellStyle(style); rowpos++; for (int a = 1; a < sectionheaders.length; a++) { HSSFCell clx = rw.createCell(a); clx.setCellValue(""); clx.setCellStyle(style); shet.setColumnWidth(a, 5000); } HSSFRow rw1 = shet.createRow(rowpos); rw1.setHeightInPoints(38); rowpos++; for (int a = 0; a < sectionheaders.length; a++) { HSSFCell clx = rw1.createCell(a); clx.setCellValue(sectionheaders[a]); clx.setCellStyle(stylex); if (a > 7 && a < sectionheaders.length) { if (sectionheaders[a].equals("")) { } else { shet.addMergedRegion(new CellRangeAddress(1, 1, a, a + 2)); } } } shet.addMergedRegion(new CellRangeAddress(0, 0, 0, sectionheaders.length - 1)); shet.setColumnWidth(0, 5000); //add section 2 HSSFRow rw2 = shet.createRow(rowpos); rw2.setHeightInPoints(25); for (int a = 0; a < 8; a++) { HSSFCell clx = rw2.createCell(a); clx.setCellValue(""); clx.setCellStyle(stylex); shet.addMergedRegion(new CellRangeAddress(rowpos - 1, rowpos, a, a)); } int b = 0; for (int a = 8; a < sectionheaders.length; a++) { HSSFCell clx = rw2.createCell(a); clx.setCellValue(subheaders[b]); b++; if (b == 3) { b = 0; } clx.setCellStyle(stylex); } rowpos++; conn.rs = conn.st.executeQuery(getexistingdata); while (conn.rs.next()) { //INSIDE WHILE LOOP //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //REMOVE SITES THAT HAVE DATA FROM THE STATIC ARRAYLIST SET //get the index of the current facility int mflindex = staticmfl.indexOf(conn.rs.getString("mflcode")); if (mflindex != -1) { //remove the element from the arraylist staticfacility.remove(mflindex); staticcounty.remove(mflindex); staticdistrict.remove(mflindex); staticmfl.remove(mflindex); staticdsd_ta.remove(mflindex); staticart_hv.remove(mflindex); statichtc_hv.remove(mflindex); staticpmtct_hv.remove(mflindex); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% int colpos = 0; int conpos = 1; HSSFRow rwx = shet.createRow(rowpos); rwx.setHeightInPoints(25); String arthv = " "; String htchv = " "; String pmtcthv = " "; if (conn.rs.getString("ART_highvolume") != null) { arthv = conn.rs.getString("ART_highvolume"); } if (conn.rs.getString("HTC_highvolume") != null) { htchv = conn.rs.getString("HTC_highvolume"); } if (conn.rs.getString("PMTCT_highvolume") != null) { pmtcthv = conn.rs.getString("PMTCT_highvolume"); } //county if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(conn.rs.getString(conpos).substring(0, 1).toUpperCase() + conn.rs.getString(conpos).substring(1).toLowerCase()); clx.setCellStyle(style2); colpos++; conpos++; } //subcounty if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(conn.rs.getString(conpos).substring(0, 1).toUpperCase() + conn.rs.getString(conpos).substring(1).toLowerCase()); clx.setCellStyle(style2); colpos++; conpos++; } //facility name if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(conn.rs.getString(conpos).substring(0, 1).toUpperCase() + conn.rs.getString(conpos).substring(1).toLowerCase()); clx.setCellStyle(style2); colpos++; conpos++; } //mfl if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(conn.rs.getString(conpos)); clx.setCellStyle(style2); colpos++; conpos++; } //support type//###################################################################################### if (1 == 1) { String support = "DSD"; if (conn.rs.getString("HTC_Support1") == null || conn.rs.getString("HTC_Support1").equals("")) { /** if(conn.rs.getString("PMTCT_Support")!=null&&!conn.rs.getString("PMTCT_Support").equals("null")){ support=conn.rs.getString("PMTCT_Support"); } **/ } else { support = conn.rs.getString("HTC_Support1"); } System.out.println("______:" + conn.rs.getString("HTC_Support1") + ":__" + support); HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(support/**"DSD"/*support*/ ); clx.setCellStyle(style2); colpos++; //skip both pmtct support s conpos++; conpos++; } //arthv if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(arthv); clx.setCellStyle(style2); colpos++; } //htchv if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(htchv); clx.setCellStyle(style2); colpos++; } //pmtcthv if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(pmtcthv); clx.setCellStyle(style2); colpos++; } //____________________Totals begin here______________ //Antenatal if (1 == 1) { //sum(HV0202) as HV0202,sum(HV0203) as HV0203,sum(HV0206) as HV0206,sum(HV0207) as HV0207,sum(HV0208) as HV0208,sum(HV0228) as HV0228,sum(HV0232) as HV0232, sum(DTCB_Test_Out_Tot) as DTCB_Test_Out_Tot,sum(DTCB_Test_In_Tot) as DTCB_Test_In_Tot , sum(DTCC_HIV_Out_Tot) as DTCC_HIV_Out_Tot, sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; positive = conn.rs.getInt("HV0206"); tested = conn.rs.getInt("HV0201"); negative = tested - positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } //Labour & Delivery if (1 == 1) { //,sum(HV0203) as HV0203,sum(HV0206) as HV0206,sum(HV0207) as HV0207,sum(HV0208) as HV0208,sum(HV0228) as HV0228,sum(HV0232) as HV0232, sum(DTCB_Test_Out_Tot) as DTCB_Test_Out_Tot,sum(DTCB_Test_In_Tot) as DTCB_Test_In_Tot , sum(DTCC_HIV_Out_Tot) as DTCC_HIV_Out_Tot, sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; positive = conn.rs.getInt("HV0207"); tested = conn.rs.getInt("HV0202"); negative = tested - positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } //Under 5 Clinic if (1 == 1) { //sum(HV0208) as HV0208,sum(HV0228) as HV0228,sum(HV0232) as HV0232, sum(DTCB_Test_Out_Tot) as DTCB_Test_Out_Tot,sum(DTCB_Test_In_Tot) as DTCB_Test_In_Tot , sum(DTCC_HIV_Out_Tot) as DTCC_HIV_Out_Tot, sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; positive = conn.rs.getInt("HV0232"); tested = conn.rs.getInt("HV0228"); negative = tested - positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } //Post Natal if (1 == 1) { //sum(HV0208) as HV0208,sum(HV0228) as HV0228,sum(HV0232) as HV0232, sum(DTCB_Test_Out_Tot) as DTCB_Test_Out_Tot,sum(DTCB_Test_In_Tot) as DTCB_Test_In_Tot , sum(DTCC_HIV_Out_Tot) as DTCC_HIV_Out_Tot, sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; positive = conn.rs.getInt("HV0208"); tested = conn.rs.getInt("HV0203"); negative = tested - positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } //------------------------------------------------------------------------------------------------------------------- //TB Stat if (1 == 1) { int tested = 0; int positive = 0; int negative = 0; String getstat = "select sum(positive) as positive ,sum(negative) as negative from tb_stat_art WHERE " + tbstatduration + " and SubPartnerID='" + conn.rs.getString("SubPartnerID") + "'"; conn.rs1 = conn.st1.executeQuery(getstat); if (conn.rs1.next()) { positive = conn.rs1.getInt("positive"); negative = conn.rs1.getInt("negative"); tested = negative + positive; //remove the current facility id if (tbstat.contains(conn.rs.getString("SubPartnerID"))) { tbstat.remove(conn.rs.getString("SubPartnerID")); } } //sum(HV0208) as HV0208,sum(HV0228) as HV0228,sum(HV0232) as HV0232, sum(DTCB_Test_Out_Tot) as DTCB_Test_Out_Tot,sum(DTCB_Test_In_Tot) as DTCB_Test_In_Tot , sum(DTCC_HIV_Out_Tot) as DTCC_HIV_Out_Tot, sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN //tested HSSFCell clx = rwx.createCell(colpos); if (!reportDuration.equals("4")) { clx.setCellValue(tested); } else { clx.setCellValue(""); } clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); if (!reportDuration.equals("4")) { clx1.setCellValue(positive); } else { clx1.setCellValue(""); } clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); if (!reportDuration.equals("4")) { clx2.setCellValue(negative); } else { clx2.setCellValue(""); } clx2.setCellStyle(style2); colpos++; } //------------------------------------------------------------------------------------------------------------------- //sexually transmitted insfections //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX COMMENTED FOR NOW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX if (1 == 2) { //sum(HV0208) as HV0208,sum(HV0228) as HV0228,sum(HV0232) as HV0232, sum(DTCB_Test_Out_Tot) as DTCB_Test_Out_Tot,sum(DTCB_Test_In_Tot) as DTCB_Test_In_Tot , sum(DTCC_HIV_Out_Tot) as DTCC_HIV_Out_Tot, sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; //positive=conn.rs.getInt("HV0208"); //tested=conn.rs.getInt("HV0203"); //negative=tested-positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } //Outpatient if (1 == 1) { // sum(DTCB_Test_In_Tot) as DTCB_Test_In_Tot , sum(DTCC_HIV_Out_Tot) as DTCC_HIV_Out_Tot, sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; positive = conn.rs.getInt("DTCC_HIV_Out_Tot"); tested = conn.rs.getInt("DTCB_Test_Out_Tot"); negative = tested - positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } //Inpatient if (1 == 1) { // sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; positive = conn.rs.getInt("DTCC_HIV_In_Tot"); tested = conn.rs.getInt("DTCB_Test_In_Tot"); negative = tested - positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } //HIV Care and Treatment //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX COMMENTED FOR NOW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX if (1 == 2) { // sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; // positive=conn.rs.getInt("DTCC_HIV_In_Tot"); //tested=conn.rs.getInt("DTCB_Test_In_Tot"); // negative=tested-positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } //VMMC if (1 == 1) { // sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; positive = conn.rs.getInt("P511KP"); negative = conn.rs.getInt("P511KN"); tested = negative + positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } //VCT (Co-located) if (1 == 1) { // sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; positive = conn.rs.getInt("VCTClient_HIV_TOT"); tested = conn.rs.getInt("VCTClient_Tested_TOT"); negative = tested - positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } //Voluntary counselling and testing (Stand alone) //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX COMMENTED FOR NOW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX if (1 == 2) { // sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; // positive=conn.rs.getInt(""); //tested=conn.rs.getInt(""); //negative=tested-positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } //Mobile //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX COMMENTED FOR NOW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX if (1 == 2) { // sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; // positive=conn.rs.getInt(""); //tested=conn.rs.getInt(""); //negative=tested-positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } //Home Based //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX COMMENTED FOR NOW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX if (1 == 2) { // sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; // positive=conn.rs.getInt(""); //tested=conn.rs.getInt(""); //negative=tested-positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } //Other //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX COMMENTED FOR NOW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX if (1 == 2) { // sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN int tested = 0; int positive = 0; int negative = 0; // positive=conn.rs.getInt(""); //tested=conn.rs.getInt(""); //negative=tested-positive; //tested HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(tested); clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); clx1.setCellValue(positive); clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); clx2.setCellValue(negative); clx2.setCellStyle(style2); colpos++; } rowpos++; } //now check if any facilities were skipped //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% System.out.println("_____======______" + tbstat.size()); for (int a = 0; a < tbstat.size(); a++) { System.out.println("%%%%%======______RoWno::" + tbstat.get(a)); if (1 == 1) { int colpos = 0; int conpos = 1; HSSFRow rwx = shet.createRow(rowpos); rwx.setHeightInPoints(25); String getstat = "select county,DistrictNom, SubPartnerNom, CentreSanteId as mflcode ,supporttype, sum(positive) as positive ,sum(negative) as negative, tb_stat_art.SubPartnerID as SubPartnerID, ART_highvolume, HTC_highvolume,PMTCT_highvolume from tb_stat_art join ( " + facilitiestable + " join (district join county on county.CountyID=district.CountyID ) on district.DistrictID = " + facilitiestable + ".DistrictID ) on tb_stat_art.SubPartnerID = " + facilitiestable + ".SubPartnerID WHERE " + tbstatduration + " and tb_stat_art.SubPartnerID='" + tbstat.get(a) + "'"; conn.rs = conn.st.executeQuery(getstat); if (conn.rs.next()) { //INSIDE WHILE LOOP //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //REMOVE SITES THAT HAVE DATA FROM THE STATIC ARRAYLIST SET //get the index of the current facility int mflindex = staticmfl.indexOf(conn.rs.getString("mflcode")); if (mflindex != -1) { //remove the element from the arraylist staticfacility.remove(mflindex); staticcounty.remove(mflindex); staticdistrict.remove(mflindex); staticmfl.remove(mflindex); staticdsd_ta.remove(mflindex); staticart_hv.remove(mflindex); statichtc_hv.remove(mflindex); staticpmtct_hv.remove(mflindex); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% String arthv = " "; String htchv = " "; String pmtcthv = " "; if (conn.rs.getString("ART_highvolume") != null) { arthv = conn.rs.getString("ART_highvolume"); } if (conn.rs.getString("HTC_highvolume") != null) { htchv = conn.rs.getString("HTC_highvolume"); } if (conn.rs.getString("PMTCT_highvolume") != null) { pmtcthv = conn.rs.getString("PMTCT_highvolume"); } //county if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(conn.rs.getString(conpos).substring(0, 1).toUpperCase() + conn.rs.getString(conpos).substring(1).toLowerCase()); clx.setCellStyle(style2); colpos++; conpos++; } //subcounty if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(conn.rs.getString(conpos).substring(0, 1).toUpperCase() + conn.rs.getString(conpos).substring(1).toLowerCase()); clx.setCellStyle(style2); colpos++; conpos++; } //facility name if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(conn.rs.getString(conpos).substring(0, 1).toUpperCase() + conn.rs.getString(conpos).substring(1).toLowerCase()); clx.setCellStyle(style2); colpos++; conpos++; } //mfl if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(conn.rs.getString(conpos)); clx.setCellStyle(style2); colpos++; conpos++; } //support type//###################################################################################### if (1 == 1) { String support = "NA"; support = conn.rs.getString("supporttype"); HSSFCell clx = rwx.createCell(colpos); clx.setCellValue("DSD" /*support*/); clx.setCellStyle(style2); colpos++; //skip both pmtct support s conpos++; } //arthv if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(arthv); clx.setCellStyle(style2); colpos++; } //htchv if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(htchv); clx.setCellStyle(style2); colpos++; } //pmtcthv if (1 == 1) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(pmtcthv); clx.setCellStyle(style2); colpos++; } //enter blanks in columns from Facility type up to the tb column if (1 == 1) { for (int c = 5; c < 17; c++) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(""); clx.setCellStyle(style2); colpos++; } } //tb stat if (1 == 1) { int tested = 0; int positive = 0; int negative = 0; // String getstat="select sum(positive) as positive ,sum(negative) as negative from tb_stat_art WHERE "+tbstatduration+" and SubPartnerID='"+tbstat.get(a)+"'"; positive = conn.rs.getInt("positive"); negative = conn.rs.getInt("negative"); tested = negative + positive; //} //sum(HV0208) as HV0208,sum(HV0228) as HV0228,sum(HV0232) as HV0232, sum(DTCB_Test_Out_Tot) as DTCB_Test_Out_Tot,sum(DTCB_Test_In_Tot) as DTCB_Test_In_Tot , sum(DTCC_HIV_Out_Tot) as DTCC_HIV_Out_Tot, sum(DTCC_HIV_In_Tot) as DTCC_HIV_In_Tot, sum(VCTClient_Tested_TOT) as VCTClient_Tested_TOT, sum(VCTClient_HIV_TOT) as VCTClient_HIV_TOT, sum(P511KP) as P511KP, sum(P511KN) as P511KN //tested HSSFCell clx = rwx.createCell(colpos); if (!reportDuration.equals("4")) { clx.setCellValue(tested); } else { clx.setCellValue(""); } clx.setCellStyle(style2); colpos++; //positive HSSFCell clx1 = rwx.createCell(colpos); if (!reportDuration.equals("4")) { clx1.setCellValue(positive); } else { clx1.setCellValue(""); } clx1.setCellStyle(style2); colpos++; //negative HSSFCell clx2 = rwx.createCell(colpos); if (!reportDuration.equals("4")) { clx2.setCellValue(negative); } else { clx2.setCellValue(""); } clx2.setCellStyle(style2); colpos++; } //end of tbstat if query //finish posting blanks to the remaining columns if (1 == 1) { for (int c = 20; c < sectionheaders.length; c++) { HSSFCell clx = rwx.createCell(colpos); clx.setCellValue(""); clx.setCellStyle(style2); colpos++; // conpos++; } } } //end of if query } //end of if 1==1 System.out.println("____" + tbstat.get(a)); rowpos++; } //end of for loop //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HSSFRow rwx = null; for (int a = 0; a < staticfacility.size(); a++) { //outer loop taking care of the no of rows rwx = shet.createRow(rowpos); rwx.setHeightInPoints(23); rowpos++; for (int z = 0; z < blankrows; z++) { //inner loop taking care of the number of columns //create a row if (z == 0) { //county HSSFCell cellcounty = rwx.createCell(0); cellcounty.setCellValue(staticcounty.get(a).toString()); cellcounty.setCellStyle(style2); } else if (z == 1) { //sub-county HSSFCell cellsubcounty = rwx.createCell(1); cellsubcounty.setCellValue(staticdistrict.get(a).toString()); cellsubcounty.setCellStyle(style2); } else if (z == 2) { //facility HSSFCell cellfacil = rwx.createCell(2); cellfacil.setCellValue(staticfacility.get(a).toString()); cellfacil.setCellStyle(style2); } else if (z == 3) { //mfl HSSFCell cellmfl = rwx.createCell(3); cellmfl.setCellValue(staticmfl.get(a).toString()); cellmfl.setCellStyle(style2); } else if (z == 4) { //dsdta HSSFCell celldsd = rwx.createCell(4); celldsd.setCellValue(staticdsd_ta.get(a).toString()); celldsd.setCellStyle(style2); } else if (z == 5) { //dsdta HSSFCell celldsd = rwx.createCell(5); celldsd.setCellValue(staticart_hv.get(a).toString()); celldsd.setCellStyle(stborder); } else if (z == 6) { //dsdta HSSFCell celldsd = rwx.createCell(6); celldsd.setCellValue(statichtc_hv.get(a).toString()); celldsd.setCellStyle(stborder); } else if (z == 7) { //dsdta HSSFCell celldsd = rwx.createCell(7); celldsd.setCellValue(staticpmtct_hv.get(a).toString()); celldsd.setCellStyle(stborder); } else if (z == blankrows - 1) { //dsdta HSSFCell celldsd = rwx.createCell(blankrows - 1); celldsd.setCellValue(""); celldsd.setCellStyle(style2); } else { HSSFCell celldata = rwx.createCell(z); celldata.setCellValue(""); celldata.setCellStyle(style2); } //end of else } //end of inner loop } //end of outer loop //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //HTC CODE FROM PMTCT and HTC #PMTCTHTC //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (2 == 2) { int less15m = 0; int less15f = 0; int gret15m = 0; int gret15f = 0; ArrayList allFacilities = new ArrayList(); allFacilities.clear(); int year, month, prevYear, maxYearMonth; String reportDuration, duration, semi_annual, quarter; String facilityName, mflcode, countyName, districtName, facilityIds, facilityId; year = month = prevYear = maxYearMonth = 0; reportDuration = duration = semi_annual = quarter = ""; facilityName = mflcode = countyName = districtName = facilityIds = facilityId = ""; String facilityIds1 = ""; facilityIds1 = "("; if (request.getParameter("subcounty") != null && !request.getParameter("subcounty").equals("")) { String subcounty = request.getParameter("subcounty"); String getDist = "SELECT " + facilitiestable + ".SubPartnerID FROM " + facilitiestable + " " + "JOIN district ON " + facilitiestable + ".DistrictID=district.DistrictID " + "WHERE district.DistrictID='" + subcounty + "'"; conn.rs = conn.st.executeQuery(getDist); while (conn.rs.next()) { allFacilities.add(conn.rs.getString(1)); facilityIds1 += " moh711.SubPartnerID='" + conn.rs.getString(1) + "' || "; } facilityIds1 = facilityIds1.substring(0, facilityIds1.length() - 3); facilityIds1 += ") && "; } else { if (request.getParameter("county") != null && !request.getParameter("county").equals("")) { String county = request.getParameter("county"); String getCounty = "SELECT " + facilitiestable + ".SubPartnerID FROM " + facilitiestable + " " + "JOIN district ON " + facilitiestable + ".DistrictID=district.DistrictID " + "JOIN county ON district.CountyID=county.CountyID WHERE county.CountyID='" + county + "'"; conn.rs = conn.st.executeQuery(getCounty); while (conn.rs.next()) { allFacilities.add(conn.rs.getString(1)); facilityIds1 += " moh711.SubPartnerID='" + conn.rs.getString(1) + "' || "; } facilityIds1 = facilityIds1.substring(0, facilityIds1.length() - 3); facilityIds1 += ") && "; } else { facilityIds1 = ""; } } int TestedAdultMale = 0, TestedAdultFemale = 0; int TestedChildMale = 0, TestedChildFemale = 0; int HIV_AdultMale = 0, HIV_AdultFemale = 0; int HIV_ChildMale = 0, HIV_ChildFemale = 0; int pmtcttested = 0; int pmtctpositive = 0; int pmtctnegative = 0; double FemaleAdultTested; double FemaleTestedChild; double AdultFemaleHIV; double ChildFemaleHIV; double MaleAdultTested; double MaleTestedChild; double AdultMaleHIV; double ChildMaleHIV; double FemaleAdultTested1 = 0; double FemaleAdultTested4 = 0; double FemaleAdultTested9 = 0; double FemaleAdultTested14 = 0; double FemaleAdultTested19 = 0; double FemaleAdultTested24 = 0; double FemaleAdultTested49 = 0; double FemaleAdultTested50 = 0; double FemaleTestedChild1 = 0; double FemaleTestedChild4 = 0; double FemaleTestedChild9 = 0; double FemaleTestedChild14 = 0; double FemaleTestedChild19 = 0; double FemaleTestedChild24 = 0; double FemaleTestedChild49 = 0; double FemaleTestedChild50 = 0; double AdultFemaleHIV19Neg = 0; double AdultFemaleHIV24Neg = 0; double AdultFemaleHIV49Neg = 0; double AdultFemaleHIV50Neg = 0; double AdultFemaleHIV19 = 0; double AdultFemaleHIV24 = 0; double AdultFemaleHIV49 = 0; double AdultFemaleHIV50 = 0; double ChildFemaleHIV1 = 0; double ChildFemaleHIV4 = 0; double ChildFemaleHIV9 = 0; double ChildFemaleHIV14 = 0; double ChildFemaleHIV1Neg = 0; double ChildFemaleHIV4Neg = 0; double ChildFemaleHIV9Neg = 0; double ChildFemaleHIV14Neg = 0; // MALES double MaleAdultTested19Neg = 0; double MaleAdultTested21Neg = 0; double MaleAdultTested49Neg = 0; double MaleAdultTested50Neg = 0; double MaleAdultTested19 = 0; double MaleAdultTested24 = 0; double MaleAdultTested49 = 0; double MaleAdultTested50 = 0; double MaleTestedChild1 = 0; double MaleTestedChild4 = 0; double MaleTestedChild9 = 0; double MaleTestedChild14 = 0; double MaleTestedChild1Neg = 0; double MaleTestedChild4Neg = 0; double MaleTestedChild9Neg = 0; double MaleTestedChild14Neg = 0; double AdultMaleHIV19Neg = 0; double AdultMaleHIV24Neg = 0; double AdultMaleHIV49Neg = 0; double AdultMaleHIV50Neg = 0; double AdultMaleHIV19 = 0; double AdultMaleHIV24 = 0; double AdultMaleHIV49 = 0; double AdultMaleHIV50 = 0; double ChildMaleHIV1 = 0; double ChildMaleHIV4 = 0; double ChildMaleHIV9 = 0; double ChildMaleHIV14 = 0; double ChildMaleHIV1Neg = 0; double ChildMaleHIV4Neg = 0; double ChildMaleHIV9Neg = 0; double ChildMaleHIV14Neg = 0; double splitData = 0; int adderPos = 0; double childSplitData = 0; int redalert = 0; year = Integer.parseInt(request.getParameter("year")); reportDuration = request.getParameter("reportDuration"); // year=2015; // reportDuration="4"; String period1 = ""; String duration1 = ""; prevYear = year - 1; maxYearMonth = 0; // GET REPORT DURATION============================================ if (reportDuration.equals("1")) { duration1 = " moh711.yearmonth BETWEEN " + prevYear + "10 AND " + year + "09"; period1 = "DATIM ANNUAL DATA REPORT FOR PEPFAR YEAR : " + year; } else if (reportDuration.equals("2")) { semi_annual = request.getParameter("semi_annual"); // semi_annual="2"; if (semi_annual.equals("1")) { duration1 = " moh711.yearmonth BETWEEN " + prevYear + "10 AND " + year + "03"; period1 = "DATIM SEMI - ANNUAL DATA REPORT FOR PERIOD : OCT " + prevYear + " to MARCH " + year; } else { duration1 = " moh711.yearmonth BETWEEN " + year + "04 AND " + year + "09"; period1 = "DATIM SEMI - ANNUAL DATA REPORT FOR PERIOD : APRIL " + year + " to SEPT " + year; } } else if (reportDuration.equals("3")) { String startMonth, endMonth; quarter = request.getParameter("quarter"); // quarter="3"; String getMonths = "SELECT months,name FROM quarter WHERE id='" + quarter + "'"; conn.rs = conn.st.executeQuery(getMonths); if (conn.rs.next() == true) { String months[] = conn.rs.getString(1).split(","); startMonth = months[0]; endMonth = months[2]; if (quarter.equals("1")) { duration1 = " moh711.yearmonth BETWEEN " + prevYear + "" + startMonth + " AND " + prevYear + "" + endMonth; period1 = "DATIM QUARTERLY DATA REPORT FOR PERIOD : " + conn.rs.getString(2).replace("-", " " + prevYear + " TO ") + " " + prevYear + ""; } else { duration1 = " moh711.yearmonth BETWEEN " + year + "" + startMonth + " AND " + year + "" + endMonth; period1 = "DATIM QUARTERLY DATA REPORT FOR PERIOD : " + conn.rs.getString(2).replace("-", " " + year + " TO ") + " " + year + ""; } } } else if (reportDuration.equals("4")) { month = Integer.parseInt(request.getParameter("month")); // month=5; String getMonthName = "SELECT name FROM month WHERE id='" + month + "'"; conn.rs = conn.st.executeQuery(getMonthName); if (conn.rs.next() == true) { if (month >= 10) { duration1 = " moh711.yearmonth=" + prevYear + "" + month; period1 = "DATIM MONTHLY DATA REPORT FOR : " + conn.rs.getString(1) + "(" + prevYear + ")"; } else { duration1 = " moh711.yearmonth=" + year + "0" + month; period1 = "DATIM MONTHLY DATA REPORT FOR : " + conn.rs.getString(1) + "(" + year + ")"; } } } else { duration1 = ""; } HSSFSheet shet3 = wb.createSheet("PMTCT , HTC ,UNDER 5 & VMMC "); HSSFCell c11; FemaleAdultTested = 0; FemaleTestedChild = 0; AdultFemaleHIV = 0; ChildFemaleHIV = 0; double TotalTested = 0; double TotalPositiveFemale = 0; double TotalPositiveMale = 0; double TotalNegativeFemale = 0; double TotalNegativeMale = 0; // MALES MaleAdultTested = 0; MaleTestedChild = 0; AdultMaleHIV = 0; ChildMaleHIV = 0; double TotalPositive = 0; double TotalNegative = 0; String county = ""; String district = ""; String facilityname = ""; HSSFCellStyle stylex = wb.createCellStyle(); stylex.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index); stylex.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); stylex.setBorderTop(HSSFCellStyle.BORDER_THIN); stylex.setBorderBottom(HSSFCellStyle.BORDER_THIN); stylex.setBorderLeft(HSSFCellStyle.BORDER_THIN); stylex.setBorderRight(HSSFCellStyle.BORDER_THIN); stylex.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFFont fontx = wb.createFont(); fontx.setColor(HSSFColor.DARK_BLUE.index); stylex.setFont(fontx); stylex.setWrapText(true); HSSFCellStyle stylemainHeader = wb.createCellStyle(); stylemainHeader.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); stylemainHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); stylemainHeader.setBorderTop(HSSFCellStyle.BORDER_THIN); stylemainHeader.setBorderBottom(HSSFCellStyle.BORDER_THIN); stylemainHeader.setBorderLeft(HSSFCellStyle.BORDER_THIN); stylemainHeader.setBorderRight(HSSFCellStyle.BORDER_THIN); stylemainHeader.setAlignment(HSSFCellStyle.ALIGN_CENTER); stylemainHeader.setWrapText(true); HSSFCellStyle styleHeader = wb.createCellStyle(); styleHeader.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); styleHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); styleHeader.setBorderTop(HSSFCellStyle.BORDER_THIN); styleHeader.setBorderBottom(HSSFCellStyle.BORDER_THIN); styleHeader.setBorderLeft(HSSFCellStyle.BORDER_THIN); styleHeader.setBorderRight(HSSFCellStyle.BORDER_THIN); styleHeader.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleHeader.setWrapText(true); HSSFCellStyle stborder = wb.createCellStyle(); stborder.setBorderTop(HSSFCellStyle.BORDER_THIN); stborder.setBorderBottom(HSSFCellStyle.BORDER_THIN); stborder.setBorderLeft(HSSFCellStyle.BORDER_THIN); stborder.setBorderRight(HSSFCellStyle.BORDER_THIN); stborder.setAlignment(HSSFCellStyle.ALIGN_LEFT); stborder.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); stborder.setWrapText(true); HSSFFont font1 = wb.createFont(); font1.setFontName("Cambria"); font1.setColor((short) 0000); stborder.setFont(font1); // for the red color HSSFCellStyle redstyle = wb.createCellStyle(); redstyle.setFillForegroundColor(HSSFColor.RED.index); redstyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); redstyle.setBorderTop(HSSFCellStyle.BORDER_THIN); redstyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); redstyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); redstyle.setBorderRight(HSSFCellStyle.BORDER_THIN); redstyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); redstyle.setWrapText(true); shet3.setColumnWidth(0, 4000); shet3.setColumnWidth(1, 5000); shet3.setColumnWidth(2, 7000); //shet3.setColumnWidth(6,5000); HSSFCell c12, c13, c14, c15, c16, c17, c18, c19, c20, c110, c111, c112, c113, c114, c115, c116, c117, c118, c219; HSSFCell c119, c120, c121, c122, c123, c124, c125, c126, c127, c128, c129, c130, c131, c132, c133, c134, c135, c136, c137; HSSFCell c211, c212, c213, c214, c215, c216, c217, cARTHV, cHTCHV, cPMTCTHV; String newheader0 = "COUNTY,SUB-COUNTY,FACILITY,MFL-CODE,TYPE OF SUPPORT,ART High Volume,HTC High Volume,PMTCT High Volume,TOTAL HIV+,TOTAL +VE(F),NUM,FEMALE(POSITIVE),,,,,,,,,MALE (POSITIVE),,,,,,,,NEGATIVE,FEMALE (NEGATIVE),,,,,,,,,MALE (NEGATIVE),,,,,,,, ,,,,,,,,"; String newheader1 = "COUNTY,SUB-COUNTY,FACILITY,MFL-CODE,TYPE OF SUPPORT,ART High Volume,HTC High Volume,PMTCT High Volume,TOTAL HIV+,TOTAL +VE(F),NUM,Paeds <15Yr,,,,Adults 15+Yr,,,,TOTAL +VE MALE,Paeds < 15Yr,,,,Adults 15+Yr,,,,TOTAL -VE(F),Paeds <15Yr,,,,Adults 15+Yr,,,,TOTAL -VE(M),Paeds <15Yr,,,,Adults 15+Yr,,,,Female,,Male,,Sub-total,Positive,Negative,Sub-total,Verification Status"; String newheader2 = "COUNTY,SUB-COUNTY,FACILITY,MFL-CODE,TYPE OF SUPPORT,ART High Volume,HTC High Volume,PMTCT High Volume,TOTAL HIV+,TOTAL +VE(F),NUM,<1,1-4Y,5-9Y,10-14Y,15-19Y,20-24Y,25-49Y,50+Y,TOTAL +VE MALE,<1,1-4Y,5-9Y,10-14Y,15-19Y,20-24Y,25-49Y,50+Y,TOTAL -VE(F),<1,1-4Y,5-9Y,10-14Y,15-19Y,20-24Y,25-49Y,50+Y,TOTAL -VE(M),<1,1-4Y,5-9Y,10-14Y,15-19Y,20-24Y,25-49Y,50+Y,< 15,15 +,< 15,15 +,Sub-total,Positive,Negative,Sub-total,Verification Status"; String header0array[] = newheader0.split(","); String header1array[] = newheader1.split(","); String header2array[] = newheader2.split(","); //create header1 HSSFRow rw0 = shet3.createRow(0); rw0.setHeightInPoints(30); HSSFCell c1, c2, c3, c4, c5, c6, c7, c8; c1 = rw0.createCell(0); //_____________________________________________________________report heading row 0 c1.setCellValue(period1); c1.setCellStyle(stylemainHeader); for (int j = 1; j <= header0array.length - 1; j++) { c1 = rw0.createCell(j); c1.setCellStyle(stylemainHeader); } //-----------------------------------row 1 header rw0 = shet3.createRow(2); rw0.setHeightInPoints(30); for (int i = 0; i < header0array.length; i++) { HSSFCell clx = rw0.createCell(i); clx.setCellValue(header0array[i]); clx.setCellStyle(stylemainHeader); } //-----------------------------------row 2 header rw0 = shet3.createRow(3); rw0.setHeightInPoints(30); for (int i = 0; i < header1array.length; i++) { HSSFCell clx = rw0.createCell(i); clx.setCellValue(header1array[i]); clx.setCellStyle(stylemainHeader); } //-----------------------------------row 3 header rw0 = shet3.createRow(4); rw0.setHeightInPoints(30); for (int i = 0; i < header2array.length; i++) { HSSFCell clx = rw0.createCell(i); clx.setCellValue(header2array[i]); clx.setCellStyle(stylemainHeader); } String mergeinfor[] = { "0,0,0,54", "2,4,0,0", "2,4,1,1", "2,4,2,2", "2,4,3,3", "2,4,4,4", "2,4,5,5", "2,4,6,6", "2,4,7,7", "2,4,8,8", "2,4,9,9", "2,4,10,10", "2,2,11,19", "2,2,20,27", "2,2,29,37", "2,2,38,45", "2,2,46,54", "3,3,11,14", "3,3,15,18", "3,3,20,23", "3,3,24,27", "3,3,29,32", "3,3,11,14", "3,3,33,36", "3,3,38,41", "3,3,42,45", "3,3,46,47", "3,3,48,49" }; //do the merging for (int d = 0; d < mergeinfor.length; d++) { if (!mergeinfor[d].equals("")) { String pos[] = mergeinfor[d].split(","); shet3.addMergedRegion(new CellRangeAddress(new Integer(pos[0]), new Integer(pos[1]), new Integer(pos[2]), new Integer(pos[3]))); } } double checkdiff = 0; int count = 4; TestedAdultMale = 0; TestedAdultFemale = 0; TestedChildMale = 0; TestedChildFemale = 0; HIV_AdultMale = 0; HIV_AdultFemale = 0; HIV_ChildMale = 0; HIV_ChildFemale = 0; //--------------------------------------------------------------------------- String facilid = ""; String facilname = ""; String dsdta = ""; //20151010 int pmtcttestedtotal = 0; int pmtctpositivestotal = 0; int pmtctnegativetotal = 0; double pmtct15to19tes = 0; double pmtct20to24tes = 0; double pmtct25to49tes = 0; double pmtct50tes = 0; double pmtct15to19pos = 0; double pmtct20to24pos = 0; double pmtct25to49pos = 0; double pmtct50pos = 0; int vmmctes = 0; int vmmcpos = 0; int vmmcneg = 0; double vmmcless1neg = 0; double vmmc1to9neg = 0; double vmmc10to14neg = 0; double vmmc15to19neg = 0; double vmmc20to24neg = 0; double vmmc25to29neg = 0; double vmmc30to49neg = 0; double vmmc50neg = 0; double vmmcless1pos = 0; double vmmc1to9pos = 0; double vmmc10to14pos = 0; double vmmc15to19pos = 0; double vmmc20to24pos = 0; double vmmc25to29pos = 0; double vmmc30to49pos = 0; double vmmc50pos = 0; double vmmcless1tes = 0; double vmmc1to9tes = 0; double vmmc10to14tes = 0; double vmmc15to19tes = 0; double vmmc20to24tes = 0; double vmmc25to29tes = 0; double vmmc30to49tes = 0; double vmmc50tes = 0; double vmmcless15 = 0; double vmmcgret15 = 0; //========================================= double under5pos = 0; double under5tes = 0; double under5neg = 0; double under5posf = 0; double under5posm = 0; double under5negf = 0; double under5negm = 0; double pmtct15to19neg = 0; double pmtct20to24neg = 0; double pmtct25to49neg = 0; double pmtct50neg = 0; //BEFORE WHILE LOOP //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ArrayList staticfacility = new ArrayList(); ArrayList staticcounty = new ArrayList(); ArrayList staticdistrict = new ArrayList(); ArrayList staticmfl = new ArrayList(); ArrayList staticdsd_ta = new ArrayList(); ArrayList staticart_hv = new ArrayList(); ArrayList statichtc_hv = new ArrayList(); ArrayList staticpmtct_hv = new ArrayList(); int blankrows = 55; String getstaticfacilities = "SELECT county.County as county,district.DistrictNom as district," // + " " + facilitiestable + ".SubPartnerNom as facility, " + facilitiestable + ".CentreSanteId as mflcode, " + facilitiestable + ".HTC_Support1 as htcsupport,ART_highvolume, HTC_highvolume,PMTCT_highvolume " + " FROM " + facilitiestable + " JOIN district ON " + facilitiestable + ".DistrictID=district.DistrictID JOIN county ON " + " district.CountyID=county.CountyID " + " WHERE (" + facilitiestable + ".HTC=1 || " + facilitiestable + ".PMTCT=1 || " + facilitiestable + ".VMMC=1) " + " GROUP BY SubPartnerID "; conn.rs = conn.st.executeQuery(getstaticfacilities); while (conn.rs.next()) { staticcounty.add(conn.rs.getString("county")); district = conn.rs.getString("district"); staticdistrict .add(district.substring(0, 1).toUpperCase() + district.substring(1).toLowerCase()); staticfacility.add(conn.rs.getString("facility")); staticmfl.add(conn.rs.getString("mflcode")); //dsdta=conn.rs.getString("htcsupport"); dsdta = "DSD"; //static as of 201606 staticdsd_ta.add(dsdta); if (conn.rs.getString("ART_highvolume") != null) { staticart_hv.add(conn.rs.getString("ART_highvolume")); } else { staticart_hv.add(""); } if (conn.rs.getString("HTC_highvolume") != null) { statichtc_hv.add(conn.rs.getString("HTC_highvolume")); } else { statichtc_hv.add(""); } if (conn.rs.getString("PMTCT_highvolume") != null) { staticpmtct_hv.add(conn.rs.getString("PMTCT_highvolume")); } else { staticpmtct_hv.add(""); } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% String get711data = "SELECT(sum(VCTClient_Tested_CF) +sum( VCTClient_Tested_AF)+sum(DTCB_Test_Out_AF)+sum(DTCB_Test_In_AF))" //ADULTS TESTED FEMALE + ",(sum(VCTClient_Tested_CM)+ sum(VCTClient_Tested_AM) + sum(DTCB_Test_Out_AM) + sum(DTCB_Test_In_AM))"//ADULTS TESTED MALES + ", (sum(VCTClient_HIV_CF)+ sum(VCTClient_HIV_AF)+sum(DTCC_HIV_In_AF)+ sum(DTCC_HIV_Out_AF))" // ADULTS HIV+ FEMALE + ",(sum(VCTClient_HIV_CM)+sum(VCTClient_HIV_AM)+ sum(DTCC_HIV_In_AM) +sum(DTCC_HIV_Out_AM)) " // ADULTS HIV+ MALE + ", (sum(DTCB_Test_Out_CF) + sum(DTCB_Test_In_CF))" // CHILDREN TOTAL TESTED FEMALE + ", (sum(DTCB_Test_Out_CM) + sum(DTCB_Test_In_CM))" // CHILDREN TOTAL TESTED MALE + ", ( sum(DTCC_HIV_In_CF)+ sum(DTCC_HIV_Out_CF))" // CHILDREN POSITIVE FEMALE + ", (sum(DTCC_HIV_In_CM)+ sum(DTCC_HIV_Out_CM)), " + " county.County,district.DistrictNom," // + " " + facilitiestable + ".SubPartnerNom," + facilitiestable + ".CentreSanteId as mflcode," + facilitiestable + ".HTC_Support1, "// CHILDREN POSITIVE MALE //======================added later 20151010 + " sum(HV0204) as PMTCTTESTED , (sum(HV0206)+sum(HV0207)+sum(HV0208) ) as PMTCTPOS "//pmtct tested and positive added on 201510 + ",SUM(P51D1) as VMMCunder1,SUM(P51D9) as VMMC1to9,SUM(P51D10) as VMMC10to14, SUM(P51D19) as VMMC15to19 , SUM(P51D24) as VMMC20to24, SUM(P51D29) as VMMC25to29, SUM(P51D49) as VMMC30to49, SUM(P51D50) as VMMC50,SUM(P51DT) as VMMCTESTED ,SUM(P511KP) as VMMCPOS, (SUM(P511KN)+SUM(P511KU)) as VMMCNEG "//vmmc added 20151016 + ",SUM(HV0232) as HV0232,SUM(HV0228) as HV0228 ,ART_highvolume, HTC_highvolume,PMTCT_highvolume"//under five + " FROM moh711 left join moh731 on moh711.ID=moh731.id left join vmmc on moh711.ID=vmmc.tableid JOIN " + facilitiestable + " " + " ON moh711.SubPartnerID=" + facilitiestable + ".SubPartnerID " + " JOIN district ON " + facilitiestable + ".DistrictID=district.DistrictID JOIN county ON " + " district.CountyID=county.CountyID " + " WHERE " + " " + facilityIds1 + " " + duration1 + " && (" + facilitiestable + ".HTC=1 || " + facilitiestable + ".PMTCT=1 || " + facilitiestable + ".VMMC=1) " + " GROUP BY moh711.SubPartnerID "; System.out.println("711 : " + get711data); conn.rs = conn.st.executeQuery(get711data); while (conn.rs.next()) { //INSIDE WHILE LOOP //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //REMOVE SITES THAT HAVE DATA FROM THE STATIC ARRAYLIST SET //get the index of the current facility int mflindex = staticmfl.indexOf(conn.rs.getString("mflcode")); if (mflindex != -1) { //remove the element from the arraylist staticfacility.remove(mflindex); staticcounty.remove(mflindex); staticdistrict.remove(mflindex); staticmfl.remove(mflindex); staticdsd_ta.remove(mflindex); staticart_hv.remove(mflindex); statichtc_hv.remove(mflindex); staticpmtct_hv.remove(mflindex); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% String arthv = " "; String htchv = " "; String pmtcthv = " "; if (conn.rs.getString("ART_highvolume") != null) { arthv = conn.rs.getString("ART_highvolume"); } if (conn.rs.getString("HTC_highvolume") != null) { htchv = conn.rs.getString("HTC_highvolume"); } if (conn.rs.getString("PMTCT_highvolume") != null) { pmtcthv = conn.rs.getString("PMTCT_highvolume"); } //=============================================now add vmmc and add under 1 county = conn.rs.getString(9); district = conn.rs.getString(10); district = district.substring(0, 1).toUpperCase() + district.substring(1).toLowerCase(); facilityname = conn.rs.getString(11); mflcode = conn.rs.getString(12); if (conn.rs.getString("HTC_Support1") == null) { dsdta = "DSD"; } else { dsdta = conn.rs.getString(13); } pmtcttestedtotal = conn.rs.getInt("PMTCTTESTED"); pmtctpositivestotal = conn.rs.getInt("PMTCTPOS"); //under 5 computations under5tes = conn.rs.getInt("HV0228"); //under5 tested under5pos = conn.rs.getInt("HV0232"); //under5 positives under5neg = under5tes - under5pos; //under 5 negatives //vmmc //VMMC50,SUM(P51DT) as VMMCTESTED ,SUM(P511KP) as VMMCPOS, SUM(P511KN) as VMMCNEG "//vmmc added 20151016 vmmcpos = conn.rs.getInt("VMMCPOS"); vmmcneg = conn.rs.getInt("VMMCNEG"); vmmctes = conn.rs.getInt("VMMCTESTED"); // SUM(P51D50) as vmmcless1tes = conn.rs.getInt("VMMCunder1"); vmmc1to9tes = conn.rs.getInt("VMMC1to9"); vmmc10to14tes = conn.rs.getInt("VMMC10to14"); vmmc15to19tes = conn.rs.getInt("VMMC15to19"); vmmc20to24tes = conn.rs.getInt("VMMC20to24"); vmmc25to29tes = conn.rs.getInt("VMMC25to29"); vmmc30to49tes = conn.rs.getInt("VMMC30to49"); vmmc50tes = conn.rs.getInt("VMMC50"); TestedAdultFemale = conn.rs.getInt(1); TestedAdultMale = conn.rs.getInt(2); HIV_AdultFemale = conn.rs.getInt(3); HIV_AdultMale = conn.rs.getInt(4); TestedChildFemale = conn.rs.getInt(5); TestedChildMale = conn.rs.getInt(6); HIV_ChildFemale = conn.rs.getInt(7); HIV_ChildMale = conn.rs.getInt(8); System.out.println(facilityname + " KKK " + HIV_AdultFemale + " " + HIV_AdultMale + " " + HIV_ChildFemale + " " + HIV_ChildMale); System.out.println(facilityname + "TestedChildFemale " + TestedChildFemale + " HIV_ChildFemale " + HIV_ChildFemale + " TestedChildMale " + TestedChildMale + " HIV_ChildMale " + HIV_ChildMale); String basicDetails = county + "@" + district + "@" + facilityname + "@" + mflcode + "@" + dsdta; String arrayDetails[] = basicDetails.split("@"); count++; rw0 = shet3.createRow(count); int facilno = 0; for (int j = 0; j < arrayDetails.length; j++) { HSSFCell S3cell = rw0.createCell(facilno); S3cell.setCellValue(arrayDetails[j]); // System.out.println(arrayDetails[j]); S3cell.setCellStyle(stborder); System.out.println("facildet pos : " + facilno + " det : " + arrayDetails[j]); facilno++; } System.out.println(facilityname + " TestedAdultFemale " + TestedAdultFemale + "TestedAdultMale " + TestedAdultMale + " TestedChildFemale " + TestedChildFemale + " TestedChildMale " + TestedChildMale + " HIV_AdultFemale " + HIV_AdultFemale + " HIV_AdultMale " + HIV_AdultMale + " HIV_ChildFemale " + HIV_ChildFemale + " HIV_ChildMale " + HIV_ChildMale); //< 1 1-9 10-14 15-19 20-24 25-29 30-49 50+ //0% 1% 45% 25% 15% 8% 6% 0% //vmmc positives double vmmcposverify = 0; double vmmcnegverify = 0; vmmc1to9pos = (float) Math.round((0.01 * vmmcpos)); vmmc10to14pos = (float) Math.round((0.45 * vmmcpos)); vmmc15to19pos = (float) Math.round((0.25 * vmmcpos)); vmmc20to24pos = (float) Math.round((0.15 * vmmcpos)); vmmc25to29pos = (float) Math.round((0.08 * vmmcpos)); vmmc30to49pos = (float) Math.round((0.06 * vmmcpos)); //do a verification before subtracting the negatives vmmcposverify = vmmc1to9pos + vmmc10to14pos + vmmc15to19pos + vmmc20to24pos + vmmc25to29pos + vmmc30to49pos; //------------------------------------------//do normalization for the tested // if the two are not equal, do a distribution double tofauti = 0; if (vmmcposverify < vmmcpos) { tofauti = vmmcpos - vmmcposverify; if (tofauti > 2) { //raise an alarm //redalert++; } //add to the male first until equal // while (tofauti > 0) { vmmc10to14pos += 1; tofauti--; } //end of while tofauti } else if (vmmcposverify > vmmcpos) { //minus until equal tofauti = vmmcposverify - vmmcpos; //add to the groupings with the larger percentage until equal //25-49 while (tofauti > 0) { vmmc10to14pos -= 1; tofauti--; } } //end of else //Now do the deductions for the negatives from the tes // vmmcless1neg=vmmcless1tes;//pos =0% // vmmc1to9neg=vmmc1to9tes-vmmc1to9pos; // vmmc10to14neg=vmmc10to14tes-vmmc10to14pos; // vmmc15to19neg=vmmc15to19tes-vmmc15to19pos; // vmmc20to24neg=vmmc20to24tes-vmmc20to24pos; // vmmc25to29neg=vmmc20to24tes-vmmc20to24pos; // vmmc30to49neg=vmmc20to24tes-vmmc20to24pos; // vmmc50neg=vmmc20to24tes;//vmmc50positives =0% //******I HAVE USED THE SAME RATIOS AS THE POSITIVE THOH THATS NOT THE CASE vmmcless1neg = (float) Math.round((0.00 * vmmcneg)); vmmc1to9neg = (float) Math.round((0.01 * vmmcneg)); vmmc10to14neg = (float) Math.round((0.45 * vmmcneg)); vmmc15to19neg = (float) Math.round((0.25 * vmmcneg)); vmmc20to24neg = (float) Math.round((0.15 * vmmcneg)); vmmc25to29neg = (float) Math.round((0.08 * vmmcneg)); vmmc30to49neg = (float) Math.round((0.06 * vmmcneg)); vmmc50neg = (float) Math.round((0.00 * vmmcneg)); //verify the negatives vmmcnegverify = vmmcless1neg + vmmc1to9neg + vmmc10to14neg + vmmc15to19neg + vmmc20to24neg + vmmc25to29neg + vmmc30to49neg + vmmc50neg; //------------------------------------------//do normalization for the tested // if the two are not equal, do a distribution tofauti = 0; if (vmmcnegverify < vmmcneg) { tofauti = vmmcneg - vmmcnegverify; if (tofauti > 2) { //raise an alarm //redalert++; } //add to the male first until equal // while (tofauti > 0) { vmmc10to14neg += 1; tofauti--; } //end of while tofauti } else if (vmmcnegverify > vmmcneg) { //minus until equal tofauti = vmmcnegverify - vmmcneg; //add to the groupings with the larger percentage until equal //25-49 while (tofauti > 0) { vmmc10to14neg -= 1; tofauti--; } } //end of else vmmcless15 = vmmcless1neg + vmmc1to9neg + vmmc10to14neg + vmmcless1pos + vmmc1to9pos + vmmc10to14pos; vmmcgret15 = vmmc15to19neg + vmmc20to24neg + vmmc25to29neg + vmmc30to49neg + vmmc50neg + vmmc15to19pos + vmmc20to24pos + vmmc25to29pos + vmmc30to49pos + vmmc50pos; // FEMALES FemaleAdultTested19 = (float) Math.round((0.05 * TestedAdultFemale)); FemaleAdultTested24 = (float) Math.round((0.11 * TestedAdultFemale)); FemaleAdultTested49 = (float) Math.round((0.72 * TestedAdultFemale)); FemaleAdultTested50 = (float) Math.round((0.12 * TestedAdultFemale)); FemaleTestedChild1 = (float) Math.round((0.05 * TestedChildFemale)); FemaleTestedChild4 = (float) Math.round((0.26 * TestedChildFemale)); FemaleTestedChild9 = (float) Math.round((0.29 * TestedChildFemale)); FemaleTestedChild14 = (float) Math.round((0.40 * TestedChildFemale)); //postive AdultFemaleHIV19 = (float) Math.round((0.02 * HIV_AdultFemale)); AdultFemaleHIV24 = (float) Math.round((0.09 * HIV_AdultFemale)); AdultFemaleHIV49 = (float) Math.round((0.79 * HIV_AdultFemale)); AdultFemaleHIV50 = (float) Math.round((0.10 * HIV_AdultFemale)); //positve ChildFemaleHIV1 = (float) Math.round((0.13 * HIV_ChildFemale)); ChildFemaleHIV4 = (float) Math.round((0.37 * HIV_ChildFemale)); ChildFemaleHIV9 = (float) Math.round((0.25 * HIV_ChildFemale)); ChildFemaleHIV14 = (float) Math.round((0.25 * HIV_ChildFemale)); // MALES MaleAdultTested19 = (float) Math.round((0.05 * TestedAdultMale)); MaleAdultTested24 = (float) Math.round((0.11 * TestedAdultMale)); MaleAdultTested49 = (float) Math.round((0.72 * TestedAdultMale)); MaleAdultTested50 = (float) Math.round((0.12 * TestedAdultMale)); MaleTestedChild1 = (float) Math.round((0.05 * TestedChildMale)); MaleTestedChild4 = (float) Math.round((0.26 * TestedChildMale)); MaleTestedChild9 = (float) Math.round((0.29 * TestedChildMale)); MaleTestedChild14 = (float) Math.round((0.40 * TestedChildMale)); //positive AdultMaleHIV19 = (float) Math.round((0.02 * HIV_AdultMale)); AdultMaleHIV24 = (float) Math.round((0.09 * HIV_AdultMale)); AdultMaleHIV49 = (float) Math.round((0.79 * HIV_AdultMale)); AdultMaleHIV50 = (float) Math.round((0.10 * HIV_AdultMale)); //positives ChildMaleHIV1 = (float) Math.round((0.13 * HIV_ChildMale)); ChildMaleHIV4 = (float) Math.round((0.37 * HIV_ChildMale)); ChildMaleHIV9 = (float) Math.round((0.25 * HIV_ChildMale)); ChildMaleHIV14 = (float) Math.round((0.25 * HIV_ChildMale)); //under 5 distribution // femalepos, malepos, femaleneg, maleneg // 50% 50% 49% 51% double under5testedverify = 0; double under5posverify = 0; double under5negverify = 0; under5posf = (float) Math.round((0.50 * under5pos)); under5posm = (float) Math.round((0.50 * under5pos)); under5negf = (float) Math.round((0.49 * under5neg)); under5negm = (float) Math.round((0.51 * under5neg)); under5posverify = under5posf + under5posm; under5negverify = under5negf + under5negm; //do normalization for the tested // if the two are not equal, do a distribution tofauti = 0; if (under5posverify < under5pos) { tofauti = under5pos - under5posverify; if (tofauti > 2) { //raise an alarm //redalert++; } //add to the male first until equal // while (tofauti > 0) { under5posm += 1; tofauti--; if (tofauti != 0) { under5posf += 1; tofauti--; } } //end of while tofauti } else if (under5posverify > under5pos) { //minus until equal tofauti = under5posverify - under5pos; //add to the groupings with the larger percentage until equal //25-49 while (tofauti > 0) { under5posm -= 1; tofauti--; if (tofauti != 0) { under5posf -= 1; tofauti--; } } } //end of else //====================normalize negatives========================== if (under5negverify < under5neg) { tofauti = under5neg - under5negverify; if (tofauti > 2) { //raise an alarm //redalert++; } //add to the groupings with the larger percentage until equal //25-49 while (tofauti > 0) { under5negm += 1; tofauti--; if (tofauti != 0) { under5negf += 1; tofauti--; } } } else if (under5negverify > under5neg) { //minus until equal tofauti = under5negverify - under5neg; //add to the groupings with the larger percentage until equal //25-49 while (tofauti > 0) { under5negm -= 1; tofauti--; if (tofauti != 0) { under5negf -= 1; tofauti--; } } } //end of under 5 distribution //15-19 20-24 25-49 //PMTCT TESTED 13.9% 27.8% 58.3% //PMTCT Posit 5.3% 17.5% 77.2% //variables to hold the total of the distributed double pmtcttestedverify = 0; double pmtctpositiveverify = 0; pmtct15to19tes = (float) Math.round((0.139 * pmtcttestedtotal)); pmtct20to24tes = (float) Math.round((0.278 * pmtcttestedtotal)); pmtct25to49tes = (float) Math.round((0.583 * pmtcttestedtotal)); pmtct15to19pos = (float) Math.round((0.053 * pmtctpositivestotal)); pmtct20to24pos = (float) Math.round((0.175 * pmtctpositivestotal)); pmtct25to49pos = (float) Math.round((0.772 * pmtctpositivestotal)); pmtcttestedverify = pmtct15to19tes + pmtct20to24tes + pmtct25to49tes; pmtctpositiveverify = pmtct15to19pos + pmtct20to24pos + pmtct25to49pos; //do normalization for the tested // if the two are not equal, do a distribution double currdiff = 0; if (pmtcttestedverify < pmtcttestedtotal) { currdiff = pmtcttestedtotal - pmtcttestedverify; if (currdiff > 2) { //raise an alarm //redalert++; } //add to the groupings with the larger percentage until equal //25-49 while (currdiff > 0) { pmtct25to49tes += 1; currdiff--; } } else if (pmtcttestedverify > pmtcttestedtotal) { //minus until equal currdiff = pmtcttestedverify - pmtcttestedtotal; //add to the groupings with the larger percentage until equal //25-49 while (currdiff > 0) { pmtct25to49tes -= 1; currdiff--; } } //do normalization for the POSITIVE // if the two are not equal, do a distribution if (pmtctpositiveverify < pmtctpositivestotal) { currdiff = pmtctpositivestotal - pmtctpositiveverify; if (currdiff > 2) { //raise an alarm //redalert++; } //add to the groupings with the larger percentage until equal //25-49 while (currdiff > 0) { pmtct25to49pos += 1; currdiff--; } } else if (pmtctpositiveverify > pmtctpositivestotal) { //minus until equal currdiff = pmtctpositiveverify - pmtctpositivestotal; //add to the groupings with the larger percentage until equal //25-49 while (currdiff > 0) { pmtct25to49pos -= 1; currdiff--; } } //now get the pmtct negatives by subtracting from the pmtct15to19neg = pmtct15to19tes - pmtct15to19pos; pmtct20to24neg = pmtct20to24tes - pmtct20to24pos; pmtct25to49neg = pmtct25to49tes - pmtct25to49pos; pmtctnegativetotal = pmtcttestedtotal - pmtctpositivestotal; // TestedAdultFemale=conn.rs.getInt(1); // TestedAdultMale=conn.rs.getInt(2); // HIV_AdultFemale=conn.rs.getInt(3); // HIV_AdultMale=conn.rs.getInt(4); // TestedChildFemale=conn.rs.getInt(5); // TestedChildMale=conn.rs.getInt(6); // HIV_ChildFemale=conn.rs.getInt(7); // HIV_ChildMale=conn.rs.getInt(8); // TotalTested=FemaleTestedChild1+FemaleTestedChild4+FemaleTestedChild9+FemaleTestedChild14+FemaleAdultTested19+FemaleAdultTested24+FemaleAdultTested49+FemaleAdultTested50+ MaleAdultTested19+MaleAdultTested24+MaleAdultTested49+MaleAdultTested50+MaleTestedChild1+MaleTestedChild4+MaleTestedChild9+MaleTestedChild14; double totalpositivesmale = 0; double totalpositivesfemale = 0; double totalpositives = 0; double totalnegatives = 0; double totalfemalehiv = 0; double totalmalehiv = 0; double totalfemaletesteddis = 0; double totalmaletesteddis = 0; double totalfemaletested = 0; double totalmaletested = 0; double negfem = 0; double negmale = 0; int redalert1 = 0; int redalert2 = 0; int redalert3 = 0; int redalert4 = 0; totalpositives = AdultFemaleHIV19 + AdultFemaleHIV24 + AdultFemaleHIV49 + AdultFemaleHIV50 + ChildFemaleHIV1 + ChildFemaleHIV4 + ChildFemaleHIV9 + ChildFemaleHIV14 + AdultMaleHIV19 + AdultMaleHIV24 + AdultMaleHIV49 + AdultMaleHIV50 + ChildMaleHIV1 + ChildMaleHIV4 + ChildMaleHIV9 + ChildMaleHIV14; totalnegatives = AdultFemaleHIV19Neg + AdultFemaleHIV24Neg + AdultFemaleHIV49Neg + AdultFemaleHIV50Neg + ChildFemaleHIV1Neg + ChildFemaleHIV4Neg + ChildFemaleHIV9Neg + ChildFemaleHIV14Neg + AdultMaleHIV19Neg + AdultMaleHIV24Neg + AdultMaleHIV49Neg + AdultMaleHIV50Neg + ChildMaleHIV1Neg + ChildMaleHIV4Neg + ChildMaleHIV9Neg + ChildMaleHIV14Neg; // total tested after distribution totalfemaletesteddis = FemaleTestedChild1 + FemaleTestedChild4 + FemaleTestedChild9 + FemaleTestedChild14 + FemaleAdultTested19 + FemaleAdultTested24 + FemaleAdultTested49 + FemaleAdultTested50; totalmaletesteddis = MaleAdultTested19 + MaleAdultTested24 + MaleAdultTested49 + MaleAdultTested50 + MaleTestedChild1 + MaleTestedChild4 + MaleTestedChild9 + MaleTestedChild14; // totaltested after distriibution double totaltestedis = 0; totaltestedis = totalfemaletesteddis + totalmaletesteddis; TotalTested = TestedChildFemale + TestedChildMale + TestedAdultMale + TestedAdultFemale; totalfemaletested = TestedAdultFemale + TestedChildFemale; totalmaletested = TestedAdultMale + TestedChildMale; //poistives totalfemalehiv = HIV_AdultFemale + HIV_ChildFemale; totalmalehiv = HIV_AdultMale + HIV_ChildMale; //+ve after dist totalpositivesfemale = AdultFemaleHIV19 + AdultFemaleHIV24 + AdultFemaleHIV49 + AdultFemaleHIV50 + ChildFemaleHIV1 + ChildFemaleHIV4 + ChildFemaleHIV9 + ChildFemaleHIV14; totalpositivesmale = AdultMaleHIV19 + AdultMaleHIV24 + AdultMaleHIV49 + AdultMaleHIV50 + ChildMaleHIV1 + ChildMaleHIV4 + ChildMaleHIV9 + ChildMaleHIV14; // // negative negfem = totalfemaletested - totalfemalehiv; negmale = totalmaletested - totalmalehiv; double checkdiff1 = 0; double checkdiff2 = 0; double checkdiff3 = 0; int redfemalealert = 0; int redmalealert = 0; int finalalert = 0; double totalcheckdiff = 0; //check a difference checkdiff = totalfemalehiv - totalpositivesfemale; // System.out.println("checkdiff female "+checkdiff1); // positive female if (checkdiff > 2 || checkdiff < -2) { redalert = 1; } // positive male checkdiff1 = totalmalehiv - totalpositivesmale; // System.out.println("checkdiff male "+checkdiff1); if (checkdiff1 > 2 || checkdiff1 < -2) { redalert1 = 1; } totalcheckdiff = TotalTested - totaltestedis; // System.out.println("dqa "+totalcheckdiff); if (totalcheckdiff > 5 || totalcheckdiff < -5) { finalalert = 1; } // checkdiff=totalfemalehiv-totalpositivesfemale; // // positive female // if(checkdiff>=2 ||checkdiff<=-2){ // redalert=1; // } // // positive male // checkdiff1=totalmalehiv-totalpositivesmale; // if(checkdiff1>=2 ||checkdiff1<=-2){ // redalert1=1; // } //// negative female // checkdiff2=negfem-totalfemaletesteddis; // if(checkdiff2>=2 ||checkdiff2<=-2){ // redalert2=1; // } // // // negativemale // checkdiff3=negmale-totalmaletesteddis; // if(checkdiff3>=2 ||checkdiff3<=-2){ // redalert3=1; // } // // totalcheckdiff=checkdiff+checkdiff1+checkdiff2+checkdiff3; // if(totalcheckdiff>=5 || totalcheckdiff<=-5){ // finalalert=1; // } adderPos = 0; double Totalhivfemale = 0; double Totalhivmale = 0; Totalhivfemale = HIV_AdultFemale + HIV_ChildFemale; Totalhivmale = HIV_AdultMale + HIV_ChildMale; splitData = 0; adderPos = 0; childSplitData = 0; // // adult female hiv+ splitData = AdultFemaleHIV19 + AdultFemaleHIV24 + AdultFemaleHIV49 + AdultFemaleHIV50; // System.out.println(facilityname + " lllll added " + splitData + " from db " + HIV_AdultFemale); adderPos = 0; while (splitData < HIV_AdultFemale) { AdultFemaleHIV49 += 1; splitData++; } splitData = AdultFemaleHIV19 + AdultFemaleHIV24 + AdultFemaleHIV49 + AdultFemaleHIV50; while (splitData > HIV_AdultFemale) { AdultFemaleHIV49 -= 1; splitData--; } //tested female adults splitData = FemaleAdultTested19 + FemaleAdultTested24 + FemaleAdultTested49 + FemaleAdultTested50; adderPos = 0; while (splitData < TestedAdultFemale) { FemaleAdultTested49 += 1; splitData++; } splitData = FemaleAdultTested19 + FemaleAdultTested24 + FemaleAdultTested49 + FemaleAdultTested50; adderPos = 0; while (splitData > TestedAdultFemale) { FemaleAdultTested49 -= 1; splitData--; } // adult male hiv+ splitData = AdultMaleHIV19 + AdultMaleHIV24 + AdultMaleHIV49 + AdultMaleHIV50; adderPos = 0; while (splitData < HIV_AdultMale) { AdultMaleHIV49 += 1; splitData++; } splitData = AdultMaleHIV19 + AdultMaleHIV24 + AdultMaleHIV49 + AdultMaleHIV50; adderPos = 0; while (splitData > HIV_AdultMale) { AdultMaleHIV49 -= 1; splitData--; } //tested male adults splitData = MaleAdultTested19 + MaleAdultTested24 + MaleAdultTested49 + MaleAdultTested50; adderPos = 0; while (splitData < TestedAdultMale) { MaleAdultTested49 += 1; splitData++; } splitData = MaleAdultTested19 + MaleAdultTested24 + MaleAdultTested49 + MaleAdultTested50; adderPos = 0; while (splitData > TestedAdultMale) { MaleAdultTested49 -= 1; splitData--; } // for child female tested childSplitData = FemaleTestedChild1 + FemaleTestedChild4 + FemaleTestedChild9 + FemaleTestedChild14; System.out.println(facilityname + " " + childSplitData + " b4 jjj " + TestedChildFemale); adderPos = 0; while (childSplitData < TestedChildFemale) { if (adderPos == 0) { FemaleTestedChild14 += 1; } if (adderPos == 1) { FemaleTestedChild9 += 1; } if (adderPos == 2) { FemaleTestedChild4 += 1; } childSplitData++; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == TestedChildFemale) { } } childSplitData = FemaleTestedChild1 + FemaleTestedChild4 + FemaleTestedChild9 + FemaleTestedChild14; adderPos = 0; while (childSplitData > TestedChildFemale) { if (adderPos == 0) { FemaleTestedChild14 -= 1; } if (adderPos == 1) { FemaleTestedChild9 -= 1; } if (adderPos == 2) { FemaleTestedChild4 -= 1; } childSplitData--; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == TestedChildFemale) { } } System.out.println(facilityname + " " + childSplitData + " after jjj " + TestedChildFemale); // for child male hiv // for child female +ve childSplitData = ChildFemaleHIV1 + ChildFemaleHIV4 + ChildFemaleHIV9 + ChildFemaleHIV14; System.out.println(facilityname + " mmmm " + childSplitData + " " + HIV_ChildFemale); adderPos = 0; double diff = 0; while (childSplitData < HIV_ChildFemale) { diff = FemaleTestedChild14 - ChildFemaleHIV14; if (adderPos == 0) { if (FemaleTestedChild14 - ChildFemaleHIV14 > 0) { ChildFemaleHIV14 += 1; } else if (FemaleTestedChild9 - ChildFemaleHIV9 > 0) { ChildFemaleHIV9 += 1; } else if (FemaleTestedChild4 - ChildFemaleHIV4 > 0) { ChildFemaleHIV4 += 1; } } if (adderPos == 1) { if (FemaleTestedChild9 - ChildFemaleHIV9 > 0) { ChildFemaleHIV9 += 1; } else if (FemaleTestedChild4 - ChildFemaleHIV4 > 0) { ChildFemaleHIV4 += 1; } else if (FemaleTestedChild14 - ChildFemaleHIV14 > 0) { ChildFemaleHIV14 += 1; } } if (adderPos == 2) { if (FemaleTestedChild4 - ChildFemaleHIV4 > 0) { ChildFemaleHIV4 += 1; } else if (FemaleTestedChild14 - ChildFemaleHIV14 > 0) { ChildFemaleHIV14 += 1; } else if (FemaleTestedChild9 - ChildFemaleHIV9 > 0) { ChildFemaleHIV9 += 1; } } childSplitData++; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == HIV_ChildFemale) { } } childSplitData = ChildFemaleHIV1 + ChildFemaleHIV4 + ChildFemaleHIV9 + ChildFemaleHIV14; adderPos = 0; while (childSplitData > HIV_ChildFemale) { if (adderPos == 0) { ChildFemaleHIV14 -= 1; } if (adderPos == 1) { ChildFemaleHIV9 -= 1; } if (adderPos == 2) { ChildFemaleHIV4 -= 1; } childSplitData--; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == HIV_ChildFemale) { } } // tested male _______________________________________________________________________ childSplitData = MaleTestedChild1 + MaleTestedChild4 + MaleTestedChild9 + MaleTestedChild14; adderPos = 0; while (childSplitData < TestedChildMale) { if (adderPos == 0) { MaleTestedChild14 += 1; } else if (adderPos == 1) { MaleTestedChild9 += 1; } else if (adderPos == 2) { MaleTestedChild4 += 1; } childSplitData++; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == TestedChildMale) { } } childSplitData = MaleTestedChild1 + MaleTestedChild4 + MaleTestedChild9 + MaleTestedChild14; adderPos = 0; while (childSplitData > TestedChildMale) { if (adderPos == 0) { MaleTestedChild14 -= 1; } else if (adderPos == 1) { MaleTestedChild9 -= 1; } else if (adderPos == 2) { MaleTestedChild4 -= 1; } childSplitData--; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == TestedChildMale) { } } // for child male +ve childSplitData = ChildMaleHIV1 + ChildMaleHIV4 + ChildMaleHIV9 + ChildMaleHIV14; adderPos = 0; while (childSplitData < HIV_ChildMale) { if (adderPos == 0) { if (MaleTestedChild14 - ChildMaleHIV14 > 0) { ChildMaleHIV14 += 1; } else if (MaleTestedChild9 - ChildMaleHIV9 > 0) { ChildMaleHIV9 += 1; } else if (MaleTestedChild4 - ChildMaleHIV4 > 0) { ChildMaleHIV4 += 1; } } else if (adderPos == 1) { if (MaleTestedChild9 - ChildMaleHIV9 > 0) { ChildMaleHIV9 += 1; } else if (MaleTestedChild4 - ChildMaleHIV4 > 0) { ChildMaleHIV4 += 1; } else if (MaleTestedChild14 - ChildMaleHIV14 > 0) { ChildMaleHIV14 += 1; } } if (adderPos == 2) { if (MaleTestedChild4 - ChildMaleHIV4 > 0) { ChildMaleHIV4 += 1; } else if (MaleTestedChild14 - ChildMaleHIV14 > 0) { ChildMaleHIV14 += 1; } else if (MaleTestedChild9 - ChildMaleHIV9 > 0) { ChildMaleHIV9 += 1; } } childSplitData++; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == HIV_ChildMale) { } } childSplitData = ChildMaleHIV1 + ChildMaleHIV4 + ChildMaleHIV9 + ChildMaleHIV14; adderPos = 0; while (childSplitData > HIV_ChildMale) { if (adderPos == 0) { ChildMaleHIV14 -= 1; } else if (adderPos == 1) { ChildMaleHIV9 -= 1; } if (adderPos == 2) { ChildMaleHIV4 -= 1; } childSplitData--; adderPos++; if (adderPos > 2) { adderPos = 0; } if (childSplitData == HIV_ChildMale) { } } /// // System.out.println("Neg nn "+ChildMaleHIV1Neg+ " "+ChildMaleHIV4Neg+" "+ChildMaleHIV9Neg+" "+ ChildMaleHIV14Neg); // System.out.println("tested nn "+MaleTestedChild1+ " "+MaleTestedChild4+" "+MaleTestedChild9+" "+ MaleTestedChild14); // System.out.println("hiv+ nnn "+ChildMaleHIV1+ " "+ChildMaleHIV4+" "+ChildMaleHIV9+" "+ ChildMaleHIV14); // // all positives //TotalPositive=AdultFemaleHIV19+AdultFemaleHIV24+AdultFemaleHIV49+AdultFemaleHIV50+AdultMaleHIV19+AdultMaleHIV24+AdultMaleHIV49+AdultMaleHIV50+ // ChildFemaleHIV1+ChildFemaleHIV4+ChildFemaleHIV9+ChildFemaleHIV14 +ChildMaleHIV1+ChildMaleHIV4+ChildMaleHIV9+ChildMaleHIV14; // //TotalNegative=AdultFemaleHIV19Neg+AdultFemaleHIV24Neg+AdultFemaleHIV49Neg+AdultFemaleHIV50Neg+AdultMaleHIV19Neg+AdultMaleHIV24Neg+AdultMaleHIV49Neg+AdultMaleHIV50Neg+ // ChildFemaleHIV1Neg+ChildFemaleHIV4Neg+ChildFemaleHIV9Neg+ChildFemaleHIV14Neg +ChildMaleHIV1Neg+ChildMaleHIV4Neg+ChildMaleHIV9Neg+ChildMaleHIV14Neg; System.out.println(facilityname + " KKK " + HIV_AdultFemale + " " + HIV_AdultMale + " " + HIV_ChildFemale + " " + HIV_ChildMale); System.out.println(facilityname + "TestedChildFemale " + TestedChildFemale + " HIV_ChildFemale " + HIV_ChildFemale + " TestedChildMale " + TestedChildMale + " HIV_ChildMale " + HIV_ChildMale); double totaltestedmale1 = 0; double totaltestedfemale1 = 0; TotalTested = TestedChildFemale + TestedChildMale + TestedAdultMale + TestedAdultFemale; totaltestedmale1 = TestedChildMale + TestedAdultMale; totaltestedfemale1 = TestedChildFemale + TestedAdultFemale; TotalPositiveFemale = HIV_ChildFemale + HIV_AdultFemale; TotalPositiveMale = HIV_ChildMale + HIV_AdultMale; TotalPositive = HIV_ChildFemale + HIV_AdultFemale + HIV_ChildMale + HIV_AdultMale; TotalNegativeFemale = totaltestedfemale1 - TotalPositiveFemale; TotalNegativeMale = totaltestedmale1 - TotalPositiveMale; TotalNegative = TotalNegativeMale + TotalNegativeFemale; //201510 //this code was added later less15f = TestedChildFemale; less15m = TestedChildMale; gret15m = TestedAdultMale; gret15f = TestedAdultFemale; // TotalNegativeFemale=AdultFemaleHIV19Neg+AdultFemaleHIV24Neg+AdultFemaleHIV49Neg+AdultFemaleHIV50Neg+ ChildFemaleHIV1Neg+ChildFemaleHIV4Neg+ChildFemaleHIV9Neg+ChildFemaleHIV14Neg; //TotalNegativeMale=AdultMaleHIV19Neg+AdultMaleHIV24Neg+AdultMaleHIV49Neg+AdultMaleHIV50Neg+ChildMaleHIV1Neg+ChildMaleHIV4Neg+ChildMaleHIV9Neg+ChildMaleHIV14Neg; // TotalTested=FemaleTestedChild1+FemaleTestedChild4+FemaleTestedChild9+FemaleTestedChild14+FemaleAdultTested19+FemaleAdultTested24+FemaleAdultTested49+FemaleAdultTested50+ MaleAdultTested19+MaleAdultTested24+MaleAdultTested49+MaleAdultTested50+MaleTestedChild1+MaleTestedChild4+MaleTestedChild9+MaleTestedChild14; // TotalPositiveFemale=AdultFemaleHIV19+AdultFemaleHIV24+AdultFemaleHIV49+AdultFemaleHIV50+ChildFemaleHIV1+ChildFemaleHIV4+ChildFemaleHIV9+ChildFemaleHIV14 ; // TotalPositiveMale=AdultMaleHIV19+AdultMaleHIV24+AdultMaleHIV49+AdultMaleHIV50+ChildMaleHIV1+ChildMaleHIV4+ChildMaleHIV9+ChildMaleHIV14; // //System.out.println(MaleTestedChild14 +" bbbbb "+ChildMaleHIV14+" mmmmm "+ (MaleTestedChild14-ChildMaleHIV14)); rw0.setHeightInPoints(25); int mypos = 0; c211 = rw0.createCell(mypos); mypos++; c212 = rw0.createCell(mypos); mypos++; c213 = rw0.createCell(mypos); mypos++; c214 = rw0.createCell(mypos); mypos++; c215 = rw0.createCell(mypos); mypos++; cARTHV = rw0.createCell(mypos); mypos++; cARTHV.setCellValue(arthv); cHTCHV = rw0.createCell(mypos); mypos++; cHTCHV.setCellValue(htchv); cPMTCTHV = rw0.createCell(mypos); mypos++; cPMTCTHV.setCellValue(pmtcthv); c216 = rw0.createCell(mypos); mypos++; c217 = rw0.createCell(mypos); mypos++; // the rest c11 = rw0.createCell(mypos); mypos++; c12 = rw0.createCell(mypos); mypos++; c13 = rw0.createCell(mypos); mypos++; c14 = rw0.createCell(mypos); mypos++; c15 = rw0.createCell(mypos); mypos++; c16 = rw0.createCell(mypos); mypos++; c17 = rw0.createCell(mypos); mypos++; c18 = rw0.createCell(mypos); mypos++; c19 = rw0.createCell(mypos); mypos++; c20 = rw0.createCell(mypos); mypos++; c110 = rw0.createCell(mypos); mypos++; c111 = rw0.createCell(mypos); mypos++; c112 = rw0.createCell(mypos); mypos++; c113 = rw0.createCell(mypos); mypos++; c114 = rw0.createCell(mypos); mypos++; c115 = rw0.createCell(mypos); mypos++; c116 = rw0.createCell(mypos); mypos++; c117 = rw0.createCell(mypos); mypos++; //c11.setCellValue(facilname); //String basicDetails=county+"@"+district+"@"+facilityname+"@"+mflcode+"@"+dsdta; c211.setCellValue(county); c212.setCellValue(district); c213.setCellValue(facilityname); c214.setCellValue(mflcode); c215.setCellValue(/*"DSD"*/dsdta); shet3.addMergedRegion(new CellRangeAddress(2, 4, 0, 0)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 1, 1)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 2, 2)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 3, 3)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 4, 4)); // Female c11.setCellValue(TotalTested + pmtcttestedtotal + under5tes + vmmctes); System.out.println(facilityname + "####### HTC: " + TotalTested + " Pmtct : " + pmtcttestedtotal + ": Under5 " + under5tes); c216.setCellValue(TotalPositive + pmtctpositivestotal + under5pos + vmmcpos); //since pmtct belongs to female double under5femalestotal = under5posf + under5negf; double under5malestotal = under5posm + under5negm; // c217.setCellValue(TotalPositiveFemale+pmtctpositivestotal+under5femalestotal); had an error c217.setCellValue(TotalPositiveFemale + pmtctpositivestotal + under5posf); shet3.addMergedRegion(new CellRangeAddress(2, 4, 5, 5)); shet3.addMergedRegion(new CellRangeAddress(2, 4, 6, 6)); shet3.addMergedRegion(new CellRangeAddress(3, 4, 7, 7)); //rem under5 are children c12.setCellValue((float) Math.round(ChildFemaleHIV1 + under5posf)); c13.setCellValue((float) Math.round(ChildFemaleHIV4)); c14.setCellValue((float) Math.round(ChildFemaleHIV9)); c15.setCellValue((float) Math.round(ChildFemaleHIV14)); c16.setCellValue((float) Math.round(AdultFemaleHIV19 + pmtct15to19pos)); c17.setCellValue((float) Math.round(AdultFemaleHIV24 + pmtct20to24pos)); c18.setCellValue((float) Math.round(AdultFemaleHIV49 + pmtct25to49pos)); c19.setCellValue((float) Math.round(AdultFemaleHIV50)); c20.setCellValue(TotalPositiveMale + under5posm + vmmcpos); //male c110.setCellValue((float) Math.round(ChildMaleHIV1 + under5posm + vmmcless1pos)); c111.setCellValue((float) Math.round(ChildMaleHIV4));//skip this for vmmc c112.setCellValue((float) Math.round(ChildMaleHIV9 + vmmc1to9pos)); c113.setCellValue((float) Math.round(ChildMaleHIV14 + vmmc10to14pos)); c114.setCellValue((float) Math.round(AdultMaleHIV19 + vmmc15to19pos)); c115.setCellValue((float) Math.round(AdultMaleHIV24 + vmmc20to24pos)); c116.setCellValue((float) Math.round(AdultMaleHIV49 + vmmc25to29pos + vmmc30to49pos));//two vmmc options c117.setCellValue((float) Math.round(AdultMaleHIV50 + vmmc50pos)); for (int i = 0; i <= 22; i++) { c11 = rw0.getCell(i); c11.setCellStyle(stborder); // System.out.println("red "+redalert +" "+redalert1) ; if (redalert == 1) { c217 = rw0.getCell(6); c217.setCellStyle(redstyle); } if (redalert1 == 1) { c20 = rw0.getCell(16); c20.setCellStyle(redstyle); } } // shet3.addMergedRegion(new CellRangeAddress(2,5,0,0)); c11 = rw0.createCell(mypos); mypos++; c12 = rw0.createCell(mypos); mypos++; c13 = rw0.createCell(mypos); mypos++; c14 = rw0.createCell(mypos); mypos++; c15 = rw0.createCell(mypos); mypos++; c16 = rw0.createCell(mypos); mypos++; c17 = rw0.createCell(mypos); mypos++; c18 = rw0.createCell(mypos); mypos++; c19 = rw0.createCell(mypos); mypos++; c110 = rw0.createCell(mypos); mypos++; c111 = rw0.createCell(mypos); mypos++; c112 = rw0.createCell(mypos); mypos++; c113 = rw0.createCell(mypos); mypos++; c114 = rw0.createCell(mypos); mypos++; c115 = rw0.createCell(mypos); mypos++; c116 = rw0.createCell(mypos); mypos++; c117 = rw0.createCell(mypos); mypos++; c118 = rw0.createCell(mypos); mypos++; c119 = rw0.createCell(mypos); mypos++; c119.setCellStyle(stborder); int neg1male = 0; int neg4male = 0; int neg9male = 0; int neg14male = 0; int neg19male = 0; int neg24male = 0; int neg49male = 0; int neg50male = 0; AdultMaleHIV19Neg = (float) Math.round(MaleAdultTested19) - (AdultMaleHIV19); AdultMaleHIV24Neg = (float) Math.round(MaleAdultTested24) - (AdultMaleHIV24); AdultMaleHIV49Neg = (float) Math.round(MaleAdultTested49) - (AdultMaleHIV49); AdultMaleHIV50Neg = (float) Math.round(MaleAdultTested50) - (AdultMaleHIV50); if (AdultMaleHIV19Neg <= -1) { neg19male = 1; } if (AdultMaleHIV24Neg <= -1) { neg24male = 1; } if (AdultMaleHIV49Neg <= -1) { neg49male = 1; } if (AdultMaleHIV50Neg <= -1) { neg50male = 1; } // child male negatives ChildMaleHIV1Neg = (float) Math.round(MaleTestedChild1) - (ChildMaleHIV1); ChildMaleHIV4Neg = (float) Math.round(MaleTestedChild4) - (ChildMaleHIV4); ChildMaleHIV9Neg = (float) Math.round(MaleTestedChild9) - (ChildMaleHIV9); ChildMaleHIV14Neg = (float) Math.round(MaleTestedChild14) - (ChildMaleHIV14); if (ChildMaleHIV1Neg <= -1) { neg1male = 1; } if (ChildMaleHIV4Neg <= -1) { neg4male = 1; } if (ChildMaleHIV9Neg <= -1) { neg9male = 1; } if (ChildMaleHIV14Neg <= -1) { neg14male = 1; } //negative int neg1female = 0; int neg4female = 0; int neg9female = 0; int neg14female = 0; int neg19female = 0; int neg24female = 0; int neg49female = 0; int neg50female = 0; ChildFemaleHIV1Neg = (float) Math.round(FemaleTestedChild1) - (ChildFemaleHIV1); ChildFemaleHIV4Neg = (float) Math.round(FemaleTestedChild4) - (ChildFemaleHIV4); ChildFemaleHIV9Neg = (float) Math.round(FemaleTestedChild9) - (ChildFemaleHIV9); ChildFemaleHIV14Neg = (float) Math.round(FemaleTestedChild14) - (ChildFemaleHIV14); if (ChildFemaleHIV1Neg <= -1) { neg1female = 1; } if (ChildFemaleHIV4Neg <= -1) { neg4female = 1; } if (ChildFemaleHIV9Neg <= -1) { neg9female = 1; } if (ChildFemaleHIV14Neg <= -1) { neg14female = 1; } System.out.println(facilityname + " fffff " + ChildFemaleHIV1Neg + " " + ChildFemaleHIV4Neg + " " + ChildFemaleHIV9Neg + " " + ChildFemaleHIV14Neg); //negative AdultFemaleHIV19Neg = (float) Math.round(FemaleAdultTested19) - (AdultFemaleHIV19); AdultFemaleHIV24Neg = (float) Math.round(FemaleAdultTested24) - (AdultFemaleHIV24); AdultFemaleHIV49Neg = (float) Math.round(FemaleAdultTested49) - (AdultFemaleHIV49); AdultFemaleHIV50Neg = (float) Math.round(FemaleAdultTested50) - (AdultFemaleHIV50); if (AdultFemaleHIV19Neg <= -1) { neg19female = 1; } if (AdultFemaleHIV24Neg <= -1) { neg24female = 1; } if (AdultFemaleHIV49Neg <= -1) { neg49female = 1; } if (AdultFemaleHIV50Neg <= -1) { neg50female = 1; } double TotalNegativeFemale1 = 0; double TotalNegativeMale1 = 0; TotalNegativeFemale1 = AdultFemaleHIV19Neg + AdultFemaleHIV24Neg + AdultFemaleHIV49Neg + AdultFemaleHIV50Neg + ChildFemaleHIV1Neg + ChildFemaleHIV4Neg + ChildFemaleHIV9Neg + ChildFemaleHIV14Neg; TotalNegativeMale1 = AdultMaleHIV19Neg + AdultMaleHIV24Neg + AdultMaleHIV49Neg + AdultMaleHIV50Neg + ChildMaleHIV1Neg + ChildMaleHIV4Neg + ChildMaleHIV9Neg + ChildMaleHIV14Neg; // negative female checkdiff2 = negfem - TotalNegativeFemale1; if (checkdiff2 > 2 || checkdiff2 < -2) { redalert2 = 1; } // negativemale checkdiff3 = negmale - TotalNegativeMale1; if (checkdiff3 > 2 || checkdiff3 < -2) { redalert3 = 1; } c11.setCellValue((float) Math.round(TotalNegativeFemale + pmtctnegativetotal + under5negf));//pmtct if for women c12.setCellValue((float) Math.round(ChildFemaleHIV1Neg + under5negf)); c13.setCellValue((float) Math.round(ChildFemaleHIV4Neg)); c14.setCellValue((float) Math.round(ChildFemaleHIV9Neg)); c15.setCellValue((float) Math.round(ChildFemaleHIV14Neg)); c16.setCellValue((float) Math.round(AdultFemaleHIV19Neg + pmtct15to19neg)); c17.setCellValue((float) Math.round(AdultFemaleHIV24Neg + pmtct20to24neg)); c18.setCellValue((float) Math.round(AdultFemaleHIV49Neg + pmtct25to49neg)); c19.setCellValue((float) Math.round(AdultFemaleHIV50Neg)); c110.setCellValue((float) Math.round(TotalNegativeMale + under5negm + vmmcneg)); c111.setCellValue((float) Math.round(ChildMaleHIV1Neg + under5negm + vmmcless1neg)); c112.setCellValue((float) Math.round(ChildMaleHIV4Neg)); c113.setCellValue((float) Math.round(ChildMaleHIV9Neg + vmmc1to9neg)); c114.setCellValue((float) Math.round(ChildMaleHIV14Neg + vmmc10to14neg)); c115.setCellValue((float) Math.round(AdultMaleHIV19Neg + vmmc15to19neg)); c116.setCellValue((float) Math.round(AdultMaleHIV24Neg + vmmc20to24neg)); c117.setCellValue((float) Math.round(AdultMaleHIV49Neg + vmmc25to29neg + vmmc30to49neg));//here we join two vmmc age sets c117.setCellStyle(stborder); c118.setCellValue((float) Math.round(AdultMaleHIV50Neg + vmmc50neg)); c118.setCellStyle(stborder); // rem under 5 are all children c119.setCellValue(less15f + under5femalestotal); c119.setCellStyle(stborder); c120 = rw0.createCell(mypos); mypos++; c120.setCellStyle(stborder); c121 = rw0.createCell(mypos); mypos++; c121.setCellStyle(stborder); c122 = rw0.createCell(mypos); mypos++; c122.setCellStyle(stborder); c123 = rw0.createCell(mypos); mypos++; c123.setCellStyle(stborder); c124 = rw0.createCell(mypos); mypos++; c124.setCellStyle(stborder); c125 = rw0.createCell(mypos); mypos++; c125.setCellStyle(stborder); c126 = rw0.createCell(mypos); mypos++; c126.setCellStyle(stborder); c127 = rw0.createCell(mypos); mypos++; c127.setCellStyle(stborder); c128 = rw0.createCell(mypos); mypos++; //this is the new addition c120.setCellValue(gret15f + pmtcttestedtotal); //add the males too c121.setCellValue(less15m + under5malestotal + vmmcless15); c122.setCellValue(gret15m + vmmcgret15); c123.setCellValue(TotalTested + pmtcttestedtotal + under5tes + vmmctes); c124.setCellValue(TotalPositive + pmtctpositivestotal + under5pos + vmmcpos); c125.setCellValue(TotalNegative + pmtctnegativetotal + under5neg + vmmcneg); c126.setCellValue(TotalTested + pmtcttestedtotal + under5tes + vmmctes); c127.setCellValue("PASSED"); System.out.println(facilityname + " jjj " + AdultMaleHIV19Neg + "__________" + AdultMaleHIV24Neg + "__________" + AdultMaleHIV49Neg + "__________" + AdultMaleHIV50Neg + "__________" + ChildMaleHIV1Neg + "__________" + ChildMaleHIV4Neg + "__________" + ChildMaleHIV9Neg + "__________" + ChildMaleHIV14Neg); for (int i = 23; i <= 43; i++) { c11 = rw0.getCell(i); c11.setCellStyle(stborder); if (redalert2 == 1) { c11 = rw0.getCell(25); c11.setCellStyle(redstyle); } if (redalert3 == 1) { c110 = rw0.getCell(34); c110.setCellStyle(redstyle); } if (finalalert == 1) { c119 = rw0.getCell(51); c119.setCellStyle(redstyle); c119.setCellValue("FAILED"); } //String PMTCT total tested and negatives //System.out.println("@@@@@@@@@@@@ PMTCT TOTAL TESTED "+pmtcttestedtotal+" :: PMTCT POSITIVE "+pmtctpositivestotal); if (neg1female == 1) { c12 = rw0.getCell(26); c12.setCellStyle(redstyle); } if (neg4female == 1) { c12 = rw0.getCell(27); c12.setCellStyle(redstyle); } if (neg9female == 1) { c13 = rw0.getCell(28); c13.setCellStyle(redstyle); } if (neg14female == 1) { c14 = rw0.getCell(29); c14.setCellStyle(redstyle); } if (neg19female == 1) { c15 = rw0.getCell(30); c15.setCellStyle(redstyle); } if (neg24female == 1) { c16 = rw0.getCell(31); c16.setCellStyle(redstyle); } if (neg49female == 1) { c17 = rw0.getCell(32); c17.setCellStyle(redstyle); } if (neg50female == 1) { c18 = rw0.getCell(33); c18.setCellStyle(redstyle); } //male if (neg1male == 1) { c111 = rw0.getCell(35); c111.setCellStyle(redstyle); } if (neg4male == 1) { c112 = rw0.getCell(36); c112.setCellStyle(redstyle); } if (neg9male == 1) { c113 = rw0.getCell(37); c113.setCellStyle(redstyle); } if (neg14male == 1) { c114 = rw0.getCell(38); c114.setCellStyle(redstyle); } if (neg19male == 1) { c115 = rw0.getCell(39); c115.setCellStyle(redstyle); } if (neg24male == 1) { c116 = rw0.getCell(40); c116.setCellStyle(redstyle); } if (neg49male == 1) { c117 = rw0.getCell(41); c117.setCellStyle(redstyle); } if (neg50male == 1) { c118 = rw0.getCell(42); c118.setCellStyle(redstyle); } } // shet3.addMergedRegion(new CellRangeAddress(2,5,20,20)); } //end of while //AFTER END OF WHILE LOOP //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for (int a = 0; a < staticfacility.size(); a++) { //outer loop taking care of the no of rows count++; rw0 = shet3.createRow(count); rw0.setHeightInPoints(23); for (int b = 0; b < blankrows; b++) { //inner loop taking care of the number of columns //create a row if (b == 0) { //county HSSFCell cellcounty = rw0.createCell(0); cellcounty.setCellValue(staticcounty.get(a).toString()); cellcounty.setCellStyle(stborder); } else if (b == 1) { //sub-county HSSFCell cellsubcounty = rw0.createCell(1); cellsubcounty.setCellValue(staticdistrict.get(a).toString()); cellsubcounty.setCellStyle(stborder); } else if (b == 2) { //facility HSSFCell cellfacil = rw0.createCell(2); cellfacil.setCellValue(staticfacility.get(a).toString()); cellfacil.setCellStyle(stborder); } else if (b == 3) { //mfl HSSFCell cellmfl = rw0.createCell(3); cellmfl.setCellValue(staticmfl.get(a).toString()); cellmfl.setCellStyle(stborder); } else if (b == 4) { //dsdta HSSFCell celldsd = rw0.createCell(4); celldsd.setCellValue(staticdsd_ta.get(a).toString()); celldsd.setCellStyle(stborder); } else if (b == 5) { //dsdta HSSFCell celldsd = rw0.createCell(5); celldsd.setCellValue(staticart_hv.get(a).toString()); celldsd.setCellStyle(stborder); } else if (b == 6) { //dsdta HSSFCell celldsd = rw0.createCell(6); celldsd.setCellValue(statichtc_hv.get(a).toString()); celldsd.setCellStyle(stborder); } else if (b == 7) { //dsdta HSSFCell celldsd = rw0.createCell(7); celldsd.setCellValue(staticpmtct_hv.get(a).toString()); celldsd.setCellStyle(stborder); } else if (b == blankrows - 1) { //dsdta HSSFCell celldsd = rw0.createCell(blankrows - 1); celldsd.setCellValue("NO DATA"); celldsd.setCellStyle(stborder); } else { HSSFCell celldata = rw0.createCell(b); celldata.setCellValue(0); celldata.setCellStyle(stborder); } //end of else } //end of inner loop } //end of outer loop //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IMPLEMENT STATIC FACILITY LIST METHOD %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (conn.conn != null) { conn.conn.close(); } if (conn.rs != null) { conn.rs.close(); } if (conn.rs1 != null) { conn.rs1.close(); } if (conn.rs2 != null) { conn.rs2.close(); } if (conn.st != null) { conn.st.close(); } if (conn.st2 != null) { conn.st2.close(); } IdGenerator IG = new IdGenerator(); String createdOn = IG.CreatedOn(); ByteArrayOutputStream outByteStream = new ByteArrayOutputStream(); wb.write(outByteStream); byte[] outArray = outByteStream.toByteArray(); response.setContentType("application/ms-excel"); response.setContentLength(outArray.length); response.setHeader("Expires:", "0"); // eliminates browser caching response.setHeader("Content-Disposition", "attachment; filename=OLD_HTC-SDP_VMMC_HTC_Generatted_On_" + createdOn + ".xls"); OutputStream outStream = response.getOutputStream(); outStream.write(outArray); outStream.flush(); outStream.close(); } catch (SQLException ex) { Logger.getLogger(datimHTCResults.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Datim.datimPMTCT.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException { session = request.getSession();//from w w w .j a v a2s .com dbConn conn = new dbConn(); Calendar ca = Calendar.getInstance(); int currentyear = ca.get(Calendar.YEAR); String mwaka = request.getParameter("year"); String facilitiestable = "subpartnera"; int selectedyear = new Integer(mwaka); if (selectedyear < currentyear) { if (selectedyear < 2014) { //db for 2014 is the smallest facilitiestable = "subpartnera2014"; } else { facilitiestable = "subpartnera" + selectedyear; } } allFacilities.clear(); // year=Integer.parseInt(request.getParameter("year")); // reportDuration=request.getParameter("reportDuration"); String headerPMTCT[] = "County,Sub County,Health Facility,MFL Code,Type of support,Numerator,Denominator,HIV-infected:Linked to ART,HIV-infected: Not linked to ART,HIV-infected : Unknown link,HIV-uninfected:Not beastfeeding,HIV-uninfected: Still breastfeeeding,HIV-uninfected:Breastfeeding unknown,Other outcomes: In care but not test done, Other outcomes:Lost to follow up,Other outcomes : Died,Other outcomes:Transferred out,Numerator,Denominator,Life-long ART:New,Life-long ART: Already on treatment at the beginning of the current pregnancy,Maternal Triple-Drug ARV,Maternal AZT,Single-dose nevirapine(with or without tail),Numerator,Infants who received a virologic test within 2 months of birth, Infants who received their first virologic HIV test between 2 and 12 months of age,Infants with a postive virologic test results within 2 months of birth, Infants with a postive virologic test resultsbetween 2 and 12 months of age,Numerator,Known postive at entry,New postives,Denominator,Numerator " .split(","); year = 2015; reportDuration = "4"; period = ""; prevYear = year - 1; maxYearMonth = 0; facilityIds = "("; pmtctpos = 0; // GET REPORT DURATION============================================ if (reportDuration.equals("1")) { duration = " moh731.yearmonth BETWEEN " + prevYear + "10 AND " + year + "09"; period = "DATIM ANNUAL DATA REPORT FOR PEPFAR YEAR : " + year; } else if (reportDuration.equals("2")) { // semi_annual=request.getParameter("semi_annual"); semi_annual = "2"; if (semi_annual.equals("1")) { duration = " moh731.yearmonth BETWEEN " + prevYear + "10 AND " + year + "03"; period = "DATIM SEMI - ANNUAL DATA REPORT FOR : OCT " + prevYear + " to MARCH " + year; } else { duration = " moh731.yearmonth BETWEEN " + year + "04 AND " + year + "09"; period = "DATIM SEMI - ANNUAL DATA REPORT FOR : APRIL " + year + " to SEPT " + year; } } else if (reportDuration.equals("3")) { String startMonth, endMonth; // quarter=request.getParameter("quarter"); quarter = "3"; String getMonths = "SELECT months,name FROM quarter WHERE id='" + quarter + "'"; conn.rs = conn.st.executeQuery(getMonths); if (conn.rs.next() == true) { String months[] = conn.rs.getString(1).split(","); startMonth = months[0]; endMonth = months[2]; if (quarter.equals("1")) { duration = " moh731.yearmonth BETWEEN " + prevYear + "" + startMonth + " AND " + prevYear + "" + endMonth; period = "DATIM QUARTERLY DATA REPORT FOR : " + conn.rs.getString(2).replace("-", " " + prevYear + " TO ") + " " + prevYear + ""; } else { duration = " moh731.yearmonth BETWEEN " + year + "" + startMonth + " AND " + year + "" + endMonth; period = "DATIM QUARTERLY DATA REPORT FOR : " + conn.rs.getString(2).replace("-", " " + year + " TO ") + " " + year + ""; } } } else if (reportDuration.equals("4")) { // month=Integer.parseInt(request.getParameter("month")); month = 5; String getMonthName = "SELECT name FROM month WHERE id='" + month + "'"; conn.rs = conn.st.executeQuery(getMonthName); if (conn.rs.next() == true) { if (month >= 10) { duration = " moh731.yearmonth=" + prevYear + "" + month; period = "DATIM MONTHLY DATA REPORT FOR : " + conn.rs.getString(1) + "(" + prevYear + ")"; } else { duration = " moh731.yearmonth=" + year + "0" + month; period = "DATIM MONTHLY DATA REPORT FOR : " + conn.rs.getString(1) + "(" + year + ")"; } } } else { duration = ""; } if (request.getParameter("subcounty") != null && !request.getParameter("subcounty").equals("")) { String subcounty = request.getParameter("subcounty"); String getDist = "SELECT " + facilitiestable + ".SubPartnerID FROM " + facilitiestable + " " + "JOIN district ON " + facilitiestable + ".DistrictID=district.DistrictID " + "WHERE district.DistrictID='" + subcounty + "'"; conn.rs = conn.st.executeQuery(getDist); while (conn.rs.next()) { allFacilities.add(conn.rs.getString(1)); facilityIds += " moh731.SubPartnerID='" + conn.rs.getString(1) + "' || "; } facilityIds = facilityIds.substring(0, facilityIds.length() - 3); facilityIds += ") && "; } else { if (request.getParameter("county") != null && !request.getParameter("county").equals("")) { String county = request.getParameter("county"); String getCounty = "SELECT " + facilitiestable + ".SubPartnerID FROM " + facilitiestable + " " + "JOIN district ON " + facilitiestable + ".DistrictID=district.DistrictID " + "JOIN county ON district.CountyID=county.CountyID WHERE county.CountyID='" + county + "'"; conn.rs = conn.st.executeQuery(getCounty); while (conn.rs.next()) { allFacilities.add(conn.rs.getString(1)); facilityIds += " moh731.SubPartnerID='" + conn.rs.getString(1) + "' || "; } facilityIds = facilityIds.substring(0, facilityIds.length() - 3); facilityIds += ") && "; } else { facilityIds = ""; } } System.out.println("period is : " + period); // GET FACILITIES TO OUTPUT................................. mflcode = countyName = districtName = facilityName = ""; // facilityId=request.getParameter("facility"); // facilityIds="403"; HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet shetPMTCT = wb.createSheet("PMTCT"); HSSFFont font = wb.createFont(); font.setFontHeightInPoints((short) 18); font.setFontName("Arial Black"); font.setColor((short) 0000); CellStyle style = wb.createCellStyle(); style.setFont(font); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFFont font2 = wb.createFont(); font2.setFontName("Arial Black"); font2.setColor((short) 0000); CellStyle style2 = wb.createCellStyle(); style2.setFont(font2); HSSFCellStyle stborder = wb.createCellStyle(); stborder.setBorderTop(HSSFCellStyle.BORDER_THIN); stborder.setBorderBottom(HSSFCellStyle.BORDER_THIN); stborder.setBorderLeft(HSSFCellStyle.BORDER_THIN); stborder.setBorderRight(HSSFCellStyle.BORDER_THIN); stborder.setAlignment(HSSFCellStyle.ALIGN_CENTER); stborder.setWrapText(true); HSSFCellStyle styleHeader = wb.createCellStyle(); styleHeader.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); styleHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); styleHeader.setBorderTop(HSSFCellStyle.BORDER_THIN); styleHeader.setBorderBottom(HSSFCellStyle.BORDER_THIN); styleHeader.setBorderLeft(HSSFCellStyle.BORDER_THIN); styleHeader.setBorderRight(HSSFCellStyle.BORDER_THIN); styleHeader.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleHeader.setWrapText(true); HSSFCellStyle styleminiHeader = wb.createCellStyle(); styleminiHeader.setFillForegroundColor(HSSFColor.ORCHID.index); styleminiHeader.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); styleminiHeader.setBorderTop(HSSFCellStyle.BORDER_THIN); styleminiHeader.setBorderBottom(HSSFCellStyle.BORDER_THIN); styleminiHeader.setBorderLeft(HSSFCellStyle.BORDER_THIN); styleminiHeader.setBorderRight(HSSFCellStyle.BORDER_THIN); styleminiHeader.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleminiHeader.setWrapText(true); HSSFFont fontHeader = wb.createFont(); fontHeader.setColor(HSSFColor.DARK_BLUE.index); styleHeader.setFont(fontHeader); styleHeader.setWrapText(true); for (int i = 3; i <= headerPMTCT.length; i++) { shetPMTCT.setColumnWidth(i, 4000); } for (int i = 0; i <= 1; i++) { shetPMTCT.setColumnWidth(i, 5000); } shetPMTCT.setColumnWidth(2, 8000); for (int i = 5; i <= 16; i++) { shetPMTCT.setColumnWidth(i, 4000); } // HSSFRow rw00shetPMTCT=shetPMTCT.createRow(1); // rw00shetPMTCT.setHeightInPoints(30); // // // HSSFCell c011; // // for(int j=0;j<headerPMTCT.length;j++){ // c011=rw00shetPMTCT.createCell(j); // c011.setCellStyle(styleHeader); // } // // // c011=rw00shetPMTCT.getCell(0); // c011.setCellValue(period); // // c011=rw00shetPMTCT.getCell(5); // c011.setCellValue("CURRENT ON ART"); // // c011=rw00shetPMTCT.getCell(16); // c011.setCellValue("NEW ON ART"); // shetPMTCT.addMergedRegion(new CellRangeAddress(1,1,5,15)); // shetPMTCT.addMergedRegion(new CellRangeAddress(1,1,16,32)); // // // HSSFRow rw0shetPMTCT = shetPMTCT.createRow(1); rw0shetPMTCT.setHeightInPoints(30); HSSFCell c001; for (int j = 0; j < headerPMTCT.length; j++) { c001 = rw0shetPMTCT.createCell(j); c001.setCellStyle(styleHeader); } c001 = rw0shetPMTCT.getCell(0); c001.setCellValue(period); c001 = rw0shetPMTCT.getCell(5); c001.setCellValue("PMTCT_FO"); c001 = rw0shetPMTCT.getCell(17); c001.setCellValue("PMTCT_ARV"); c001 = rw0shetPMTCT.getCell(24); c001.setCellValue("PMTCT_EID"); c001 = rw0shetPMTCT.getCell(29); c001.setCellValue("PMTCT_STAT (Numerator)"); c001 = rw0shetPMTCT.getCell(32); c001.setCellValue("PMTCT_STAT (Denominator)"); c001 = rw0shetPMTCT.getCell(33); c001.setCellValue("PMTCT_CTX"); shetPMTCT.addMergedRegion(new CellRangeAddress(1, 1, 0, 4)); shetPMTCT.addMergedRegion(new CellRangeAddress(1, 1, 5, 16)); shetPMTCT.addMergedRegion(new CellRangeAddress(1, 1, 17, 23)); shetPMTCT.addMergedRegion(new CellRangeAddress(1, 1, 24, 28)); shetPMTCT.addMergedRegion(new CellRangeAddress(1, 1, 29, 31)); // shetPMTCT.addMergedRegion(new CellRangeAddress(2,2,25,32)); HSSFRow rw2shetPMTCT = shetPMTCT.createRow(2); rw2shetPMTCT.setHeightInPoints(50); HSSFCell c11; for (int headerpos = 0; headerpos < headerPMTCT.length; headerpos++) { String headerInfor = headerPMTCT[headerpos]; c11 = rw2shetPMTCT.createCell(headerpos); c11.setCellValue(headerInfor); c11.setCellStyle(styleHeader); } System.out.println("art header length : " + headerPMTCT.length); pmtctpos = 3; // MAIN QUERY HERE --------------------------------------------- String getPMTCTData = "SELECT " + facilitiestable + ".SubPartnerNom,district.DistrictNom,county.County," + "" + facilitiestable + ".CentreSanteId,ART_Support,PMTCT_Support," + "SUM(HV0308),SUM(HV0309),SUM(HV0310),SUM(HV0311),SUM(HV0312)," + "SUM(HV0320),SUM(HV0321),SUM(HV0322),SUM(HV0323),SUM(HV0324)," + "" + facilitiestable + ".SubPartnerID," + "SUM(HV0205),SUM(HV0209),SUM(HV0210),SUM(HV0216),SUM(HV0217)," + "SUM(HV0224),SUM(HV0225),SUM(HV0227),SUM(HV0229),SUM(HV0230),SUM(HV0231),SUM(HV0232)," + "SUM(HV0301),SUM(HV0206),SUM(HV0207),SUM(HV0208) " + " FROM moh731 JOIN " + facilitiestable + " " + "ON moh731.SubPartnerID=" + facilitiestable + ".SubPartnerID " + "JOIN district ON " + facilitiestable + ".DistrictID=district.DistrictID JOIN county ON " + "district.CountyID=county.CountyID" + " WHERE " + " " + facilityIds + " " + duration + " && (" + facilitiestable + ".PMTCT=1 || ART=1) " + "GROUP BY moh731.SubPartnerID "; System.out.println("new : " + getPMTCTData); conn.rs = conn.st.executeQuery(getPMTCTData); while (conn.rs.next()) { PMTCT_FO_I_N = PMTCT_FO_I_D = PMTCT_FO_I_LINKED = PMTCT_FO_I_NOT_LINKED = PMTCT_FO_I_UNKNOWN = PMTCT_FO_U_NOT_BREASTFEEDING = PMTCT_FO_U_STILL_BREASTFEEDING = PMTCT_FO_U_BREASTFEEDING_UNKNOWN = PMTCT_FO_OTHER_INCARE = PMTCT_FO_OTHER_NOFOLLOWUP = PMTCT_FO_DIED = PMTCT_FO_TRANSFERRED = 0.0; PMTCT_ARV_N = PMTCT_ARV_D = PMTCT_ARV_LIFELONGART_NEW = PMTCT_ARV_LIFELONGART_EXISTING = PMTCT_ARV_MATERNAL_TRIPLEDRUG_ARV = PMTCT_ARV_MATERNAL_AZT = PMTCT_ARV_SINGLEDOSE = 0.0; PMTCT_EID_N = PMTCT_EID_VIRO_2MONTHS = PMTCT_EID_VIRO_2_12MONTHS = PMTCT_EID_P_VIRO_2MONTHS = PMTCT_EID_P_VIRO_2_12MONTHS = 0.0; PMTCT_STATN_N = PMTCT_STATN_KNOWNPOSTIVE = PMTCTN_STAT_NEWPOSTIVE = 0.0; PMTCT_STATD_D = PMTCT_STATD_LESS15 = PMTCT_STATD_15_19 = PMTCT_STATD_20_24 = PMTCT_STATD_25 = 0.0; PMTCT_CTX = 0.0; facilityName = conn.rs.getString(1); districtName = conn.rs.getString(2); countyName = conn.rs.getString(3); mflcode = conn.rs.getString(4); PMTCTSupport = conn.rs.getString(6); HV0205 = conn.rs.getInt(18); HV0209 = conn.rs.getInt(19); HV0210 = conn.rs.getInt(20); HV0216 = conn.rs.getInt(21); HV0217 = conn.rs.getInt(22); HV0224 = conn.rs.getInt(23); HV0225 = conn.rs.getInt(24); HV0227 = conn.rs.getInt(25); HV0229 = conn.rs.getInt(26); HV0230 = conn.rs.getInt(27); HV0231 = conn.rs.getInt(28); HV0232 = conn.rs.getInt(29); HV0301 = conn.rs.getInt(30); HV0206 = conn.rs.getInt(31); HV0207 = conn.rs.getInt(32); HV0208 = conn.rs.getInt(33); // PMTCT_FO_I_N=(double) HV0210; // PMTCT_FO_I_D=(double)Math.round((1.03*HV0210)); // PMTCT_FO=================================================================================================== // PMTCT_ARV=================================================================================================== PMTCT_ARV_N = (double) HV0217; PMTCT_ARV_D = (double) HV0209; PMTCT_ARV_LIFELONGART_NEW = (double) Math.round((0.75 * HV0217)); PMTCT_ARV_LIFELONGART_EXISTING = (double) Math.round((0.25 * HV0217)); double normalizer = PMTCT_ARV_LIFELONGART_NEW + PMTCT_ARV_LIFELONGART_EXISTING; int pmtctnum = 0; while (HV0217 > normalizer) { if (pmtctnum < 3) { PMTCT_ARV_LIFELONGART_NEW++; } else { PMTCT_ARV_LIFELONGART_EXISTING++; } if (pmtctnum == 3) { pmtctnum = 0; } normalizer++; pmtctnum++; } normalizer = PMTCT_ARV_LIFELONGART_NEW + PMTCT_ARV_LIFELONGART_EXISTING; pmtctnum = 0; while (normalizer > HV0217) { if (pmtctnum < 3) { PMTCT_ARV_LIFELONGART_NEW--; } else { PMTCT_ARV_LIFELONGART_EXISTING--; } if (pmtctnum == 3) { pmtctnum = 0; } normalizer--; pmtctnum++; } PMTCT_ARV_MATERNAL_TRIPLEDRUG_ARV = 0.0; PMTCT_ARV_MATERNAL_AZT = 0.0; PMTCT_ARV_SINGLEDOSE = 0.0; // PMTCT_EID=================================================================================================== PMTCT_EID_N = (double) (HV0224 + HV0225 + HV0227); PMTCT_EID_VIRO_2MONTHS = (double) (HV0224); PMTCT_EID_VIRO_2_12MONTHS = (double) (HV0225 + HV0227); PMTCT_EID_P_VIRO_2MONTHS = (double) (HV0229); PMTCT_EID_P_VIRO_2_12MONTHS = (double) (HV0230 + HV0231); // PMTCT_STAT NUMERATOR====================================================================================================== PMTCT_STATN_N = (double) HV0210; PMTCT_STATN_KNOWNPOSTIVE = (double) HV0205; PMTCTN_STAT_NEWPOSTIVE = (double) (HV0206 + HV0207 + HV0208); PMTCT_STATD_D = (double) Math.round((1.03 * HV0210)); // PMTCT_CTX===================================================================================================== PMTCT_CTX = (double) HV0301; //Mo clarification whether to um or take most recent // String dataPMTCT []=(countyName+","+districtName+","+facilityName+","+mflcode+","+PMTCTSupport+","+PMTCT_FO_I_N+"," // + ""+PMTCT_FO_I_D+","+PMTCT_FO_I_LINKED+","+PMTCT_FO_I_NOT_LINKED+","+PMTCT_FO_I_UNKNOWN+"," // + ""+PMTCT_FO_U_NOT_BREASTFEEDING+","+PMTCT_FO_U_STILL_BREASTFEEDING+","+PMTCT_FO_U_BREASTFEEDING_UNKNOWN+"," // +PMTCT_FO_OTHER_INCARE+","+PMTCT_FO_OTHER_NOFOLLOWUP+","+PMTCT_FO_DIED+","+PMTCT_FO_TRANSFERRED+"," // + ""+PMTCT_ARV_N+","+PMTCT_ARV_D+","+PMTCT_ARV_LIFELONGART_NEW+","+PMTCT_ARV_LIFELONGART_EXISTING+"," // +PMTCT_ARV_MATERNAL_TRIPLEDRUG_ARV+","+PMTCT_ARV_MATERNAL_AZT+"," // + ""+PMTCT_ARV_SINGLEDOSE+","+PMTCT_EID_N+","+PMTCT_EID_VIRO_2MONTHS+","+PMTCT_EID_VIRO_2_12MONTHS+"," // +PMTCT_EID_P_VIRO_2MONTHS+","+PMTCT_EID_P_VIRO_2_12MONTHS+"," // + ""+PMTCT_STATN_N+","+PMTCT_STATN_KNOWNPOSTIVE+","+PMTCTN_STAT_NEWPOSTIVE+"," // + ""+PMTCT_STATD_D+","+PMTCT_CTX).split(","); if (PMTCTSupport != null) { // HAVE FORMULAS HERE AND THE OUTPUT FOR PMTCT String dataPMTCT[] = (countyName + "," + districtName + "," + facilityName + "," + mflcode + "," + PMTCTSupport + ",," + " ,,,,,,,,,,," + "" + PMTCT_ARV_N + "," + PMTCT_ARV_D + "," + PMTCT_ARV_LIFELONGART_NEW + "," + PMTCT_ARV_LIFELONGART_EXISTING + "," + PMTCT_ARV_MATERNAL_TRIPLEDRUG_ARV + "," + PMTCT_ARV_MATERNAL_AZT + "," + "" + PMTCT_ARV_SINGLEDOSE + "," + PMTCT_EID_N + "," + PMTCT_EID_VIRO_2MONTHS + "," + PMTCT_EID_VIRO_2_12MONTHS + "," + PMTCT_EID_P_VIRO_2MONTHS + "," + PMTCT_EID_P_VIRO_2_12MONTHS + "," + "" + PMTCT_STATN_N + "," + PMTCT_STATN_KNOWNPOSTIVE + "," + PMTCTN_STAT_NEWPOSTIVE + "," + "" + PMTCT_STATD_D + ",").split(","); HSSFRow rw3shetPMTCT = shetPMTCT.createRow(pmtctpos); rw3shetPMTCT.setHeightInPoints(25); for (int positionPMTCT = 0; positionPMTCT < dataPMTCT.length; positionPMTCT++) { String value = dataPMTCT[positionPMTCT]; c11 = rw3shetPMTCT.createCell(positionPMTCT); if (positionPMTCT > 16 && positionPMTCT < (dataPMTCT.length)) { c11.setCellValue(Double.parseDouble(value)); } else { c11.setCellValue(value); } c11.setCellStyle(stborder); if (positionPMTCT == 5 || positionPMTCT == 6 || positionPMTCT == 17 || positionPMTCT == 18 || positionPMTCT == 24 || positionPMTCT == 29 || positionPMTCT == 32 || positionPMTCT == 33) { c11.setCellStyle(styleHeader); } } pmtctpos++; } } if (conn.st != null) { conn.st.close(); } if (conn.st1 != null) { conn.st1.close(); } if (conn.st2 != null) { conn.st2.close(); } if (conn.rs != null) { conn.rs.close(); } if (conn.rs1 != null) { conn.rs1.close(); } if (conn.rs2 != null) { conn.rs2.close(); } if (conn.conn != null) { conn.conn.close(); } IdGenerator IG = new IdGenerator(); createdOn = IG.CreatedOn(); // write it as an excel attachment ByteArrayOutputStream outByteStream = new ByteArrayOutputStream(); wb.write(outByteStream); byte[] outArray = outByteStream.toByteArray(); response.setContentType("application/ms-excel"); response.setContentLength(outArray.length); response.setHeader("Expires:", "0"); // eliminates browser caching response.setHeader("Content-Disposition", "attachment; filename=PMTCT_DATIM_SPECIAL_REPORT_CREATED_ON_" + createdOn.trim() + ".xls"); OutputStream outStream = response.getOutputStream(); outStream.write(outArray); outStream.flush(); }