public static int getBillTotalCost(int billId) {
        int total = 0;

        String query = "SELECT ifNull(sum(`cost` * `quantity`),0) + `consultationCost` as `total` "
                + "FROM `bill` "
                + "LEFT JOIN `billItem` on `bill`.`billId` = `billItem`.`billId` "
                + "LEFT JOIN `medicine` on `billItem`.`medicineid` = `medicine`.`id` "
                + "WHERE `bill`.`billId` = '%d' "
                + "group by `bill`.`billid`;";

        DBA dba = Helper.getDBA();

        try {
            ResultSet rs = dba.executeQuery(String.format(query, billId));

            if (rs != null) {

                while (rs.next()) {
                    total = rs.getInt("total");
                }

                rs.close();

            }
            dba.closeConnections();
        } catch (SQLException sqlEx) {
            dba.closeConnections();
            Helper.logException(sqlEx);
        }

        return total;
    }