/* * Created on 22-nov-2005 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package com.tarisan.servlets; import com.tarisan.util.*; import com.tarisan.control.Constantes; import com.tarisan.data.Usuario; import com.tarisan.data.Paciente; import com.tarisan.log.*; import com.tarisan.util.Utilidades; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Calendar; import jakarta.servlet.http.*; import jakarta.servlet.ServletException; import jakarta.servlet.ServletOutputStream; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; //import com.lowagie.text.Chunk; //import com.lowagie.text.Document; //import com.lowagie.text.DocumentException; //import com.lowagie.text.pdf.PdfWriter; import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf.text.pdf.PdfPTable; import com.itextpdf.text.Document; import com.itextpdf.text.Element; import java.util.ArrayList; //import com.lowagie.text.*; //import com.lowagie.text.pdf.PdfWriter; //import com.lowagie.text.pdf.PdfPTable; import java.io.FileOutputStream; /** * @author Roumen * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class GestorImpresion extends HttpServlet { /** a possible status */ public static final int ACT_INIT = 0; /** a possible status */ public static final int ACT_REPORT_1 = 1; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doWork(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doWork(request, response); } /** * The actual business logic. * * @param requ the request object * @param resp the response object * @throws ServletException * @throws IOException */ public void doWork(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("Dentro de Servlet: 1"); LogTarisan.logger.log(NivelLog.INFO, "Inicio página de impresion de analitica (imp/impAnalitica.jsp)"); response.setHeader("Expires", "0"); response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache"); HttpSession sesion = request.getSession(true); int opcion = 0; if (request.getParameter("opcion") != null) { opcion = Integer.parseInt((String)request.getParameter("opcion")); System.out.println("opcion: " + opcion); switch(opcion) { case Constantes.OPC_PAC_PRESCRIPCION_ANALITICA: { try { // Definicion de variables SimpleDateFormat sdfFormateadorFecha=new SimpleDateFormat("dd/MM/yyyy"); java.sql.Date dtFecha = new java.sql.Date(Calendar.getInstance().getTime().getTime()); String strMensajeSinElementos="No ha seleccionado ningún acto médico."; // ArrayList que contedrá las descripciones de analíticas ArrayList arrayListaElementosPrescripcion = null; String strAutorizacion = "CSM"; if ((String)request.getAttribute("autorizacion") != null) { strAutorizacion = (String)request.getAttribute("autorizacion"); System.out.println("Dentro de impAnalitica.jsp: " + strAutorizacion); } String strInforme = "INFORME"; if (request.getParameter("informePrescripcion") != null) { strInforme =(String)request.getParameter("informePrescripcion"); System.out.println("Informe: " + strInforme); } // String strInforme = (String)request.getParameter("informe"); String strListaElementosPrescripcion = ""; String strListaElementosPrescripcionAux = ""; if (request.getParameter("listaElementosPrescripcion") != null ) { // Lista de elementos de Prescripción strListaElementosPrescripcion = (String)request.getParameter("listaElementosPrescripcion"); System.out.println("1"); if (strListaElementosPrescripcion != null && strListaElementosPrescripcion.length() > 0) { System.out.println("listaElementosPrescripcion original" + strListaElementosPrescripcion); } System.out.println("2"); if (strListaElementosPrescripcion != null && strListaElementosPrescripcion.length() > 0) { System.out.println("listaElementosPrescripcion original" + strListaElementosPrescripcion); strListaElementosPrescripcionAux = strListaElementosPrescripcion.replace('\'', '~'); } System.out.println("3"); strListaElementosPrescripcion = strListaElementosPrescripcionAux; System.out.println("4"); System.out.println("listaElementosPrescripcion tras replace " + strListaElementosPrescripcion); System.out.println("5"); while(strListaElementosPrescripcion.indexOf("~") != -1) { System.out.println("aaaa"); strListaElementosPrescripcion = strListaElementosPrescripcion.replace('~','\''); } System.out.println("6"); System.out.println("listaElementosPrescripcion tras replace " + strListaElementosPrescripcion); System.out.println("7"); // Vector vElementosPrescripcion = new Vector(); arrayListaElementosPrescripcion = new ArrayList(); System.out.println("8"); if (strListaElementosPrescripcion != null && strListaElementosPrescripcion.length() > 0) { // Lista no vacía System.out.println("9"); strListaElementosPrescripcion = strListaElementosPrescripcion.substring(strListaElementosPrescripcion.indexOf("¬") + 1); System.out.println("10"); //Separamos las diferentes determinaciones int i = 0; while (strListaElementosPrescripcion.indexOf("¬") != -1) { System.out.println("BUCLE i: " + i); //vElementosPrescripcion.add(strListaElementosPrescripcion.substring(0, strListaElementosPrescripcion.indexOf("¬"))); arrayListaElementosPrescripcion.add(strListaElementosPrescripcion.substring(0, strListaElementosPrescripcion.indexOf("¬"))); //System.out.println("11"); strListaElementosPrescripcion = strListaElementosPrescripcion.substring(strListaElementosPrescripcion.indexOf("¬") + 1); //System.out.println("12"); i++; } /* for (int j=0;j"); out.println(""); out .println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); } private void formular(ServletOutputStream out, HttpServletRequest request,HttpServletResponse response, int sub) throws IOException { out.print("
"); out.print("preview
"); out.println(""); out.println("
"); if (sub != ACT_INIT) { if (request.getParameter("preview") != null) { out.println(""); } else { out.print("