public void drugEstimationForPatient(int patientId, JTextPane pane){
        DB.db.openConnection();
        try {
            ResultSet res = DB.db.prescription();
            StringBuffer drug = new StringBuffer();
            double costBeforeTax = 0;
            double tps = 0.05;
            double tvq = 0.09975;
            double totalCost = 0;
            int currPrescr = -1;
            while (res.next()) {
                if (res.getInt("patientid") == patientId && res.getInt("id") > currPrescr) {
                    currPrescr = res.getInt("id");
                }
            }
            if (currPrescr != -1) {
                res = DB.db.prescription(currPrescr);
                String[] drugId = null;

                drug.append("<table width='500px'>");
//                drug.append("<table>");
                while (res.next()) {
                    String tmp = res.getString("drugid");
                    tmp.trim();
                    tmp = tmp.substring(1, tmp.length() - 1);
                    drugId = tmp.split("[|]");
                }
                for (int i = 0; i < drugId.length; i++) {
                    res = DB.db.drugs(Integer.parseInt(drugId[i]));
                    while (res.next()) {
                        drug.append("<tr><td><b>");
                        drug.append(res.getString("name"));
                        drug.append("</b></td><td>");
                        drug.append(res.getString("dose"));
                        drug.append("</td><td></td><td><b>$");
                        drug.append(res.getDouble("price"));
                        drug.append("</b></td>");
                        drug.append("<td>");
                        if(res.getString("remburs").equalsIgnoreCase("y")){
                            drug.append("reimbursable");
                            drug.append("</td></tr>");
                            drug.append("<tr><td><span style=font-size:11pt>");
                            drug.append(res.getString("name"));
                            drug.append("</span></td><td><span style=font-size:11pt>");
                            drug.append(res.getString("dose"));
                            drug.append("</span></td><td></td><td><b>$0.00");
                            drug.append("</b></td></tr>");
                        } else {
                            drug.append("non reimbursable");
                            costBeforeTax += res.getDouble("price");
                            drug.append("</td></tr>");
                        }
                        
                    }
                }

            }
            drug.append("</table><hr /><table width='415px'>");
//            drug.append("</table><hr /><table>");
            drug.append("<tr></td><td><td>Cost before taxes</td>");
            drug.append("<td></td><td><b>$");
            drug.append(costBeforeTax);
            drug.append("</b></td></tr>");
            drug.append("<tr></td><td><td>T.P.S</td>");
            drug.append("<td></td><td><b>$");
            drug.append(String.format("%.2f", (costBeforeTax * tps)));
            drug.append("</b></td></tr>");
            drug.append("<tr></td><td><td>T.V.Q</td>");
            drug.append("<td></td><td><b>$");
            drug.append(String.format("%.2f", (costBeforeTax * tvq)));
            drug.append("</b></td></tr>");
            drug.append("<tr></tr><tr><td></td><td>TOTAL</td>");
            drug.append("<td></td><td><b>$");
            drug.append(String.format("%.2f", (costBeforeTax * (1+tvq+tps))));
            drug.append("</b></td></tr>");
            drug.append("</table>");

            pane.setText(drug.toString());
            DB.db.close();
        } catch (SQLException ex) {
            Logger.getLogger(Func.class.getName()).log(Level.SEVERE, null, ex);
            DB.db.close();
        }


    }