197 lines
6.8 KiB
Plaintext
197 lines
6.8 KiB
Plaintext
<%@ page import="java.net.*" %>
|
|
<%@ page import="java.io.*" %>
|
|
<%@ page import="org.xml.sax.*" %>
|
|
<%@ page import="org.w3c.dom.*" %>
|
|
<%@ page import="java.lang.*" %>
|
|
<%@ page import="java.security.MessageDigest" %>
|
|
<%@ page import="java.security.NoSuchAlgorithmException" %>
|
|
<%@ page import="javax.xml.parsers.*" %>
|
|
<%@ page import="com.tarisan.control.*" %>
|
|
<%@ page import="com.tarisan.data.*" %>
|
|
<%@ page import="com.tarisan.excepcion.*" %>
|
|
<%@ page import="com.tarisan.log.*" %>
|
|
<%@ page import="java.util.Vector" %>
|
|
<%@ page import="java.util.Calendar" %>
|
|
<%@ page import="java.math.BigDecimal"%>
|
|
<%@ page import="java.text.SimpleDateFormat" %>
|
|
<%@ page import="com.tarisan.persistencia.PersistenciaParametros" %>
|
|
|
|
<%
|
|
//LogTarisan.logger.log(NivelLog.INFO, "Inicio página de resultados analitica (resultado_analitica.jsp)");
|
|
response.setHeader("Expires", "0");
|
|
response.setHeader("Pragma", "no-cache");
|
|
response.setHeader("Cache-Control", "no-cache");
|
|
HttpSession sesion = request.getSession(true);
|
|
|
|
if(sesion.isNew() || (sesion.getAttribute("USUARIO") == null))
|
|
{
|
|
LogTarisan.logger.log(NivelLog.INFO, "Sesión invalidada");
|
|
response.sendRedirect(request.getContextPath() + "/html/login.html");
|
|
}
|
|
else
|
|
{
|
|
LogTarisan.logger.log(NivelLog.INFO, ((Usuario)sesion.getAttribute("USUARIO")).getMedico() + " - Inicio página de resultados analitica (resultado_analitica.jsp)");
|
|
|
|
|
|
%>
|
|
<%!
|
|
static StringBuffer hexValue(byte[] buffer) {
|
|
StringBuffer sbRet=new StringBuffer(buffer.length*2);
|
|
for (int i=0; i<buffer.length; i++) {
|
|
// note: & 0xff is used to reset high bits
|
|
if ((buffer[i]>=0)&&(buffer[i]<=15)) sbRet.append("0"+Integer.toHexString(buffer[i]&0xff));
|
|
else sbRet.append(Integer.toHexString(buffer[i]&0xff));
|
|
}
|
|
return sbRet;
|
|
}
|
|
|
|
static String Encrypt(String pPlainPassword)
|
|
{
|
|
StringBuffer hexHashedPassword;
|
|
|
|
try
|
|
{
|
|
if (pPlainPassword==null) hexHashedPassword=null;
|
|
else
|
|
{
|
|
MessageDigest hash = MessageDigest.getInstance("MD5");
|
|
hash.update(pPlainPassword.getBytes());
|
|
hexHashedPassword = hexValue(hash.digest());
|
|
}
|
|
} catch (NoSuchAlgorithmException ex) {
|
|
hexHashedPassword=null;
|
|
}
|
|
return hexHashedPassword.toString() ;
|
|
}
|
|
|
|
static String crypt_txt(String en, String clau, String func)
|
|
{
|
|
|
|
String m = "";
|
|
char c = 'a';
|
|
if (en==null) return null;
|
|
if (en.length()==0) return "";
|
|
if (clau.compareTo("NOENCRPT") == 0) return en;
|
|
if (clau.compareTo("") == 0) clau = "iN3a1Abh";
|
|
|
|
if (func.compareTo("XE") == 0)
|
|
{
|
|
// Encriptar...
|
|
StringBuffer sbRet=new StringBuffer(en.length()*2);
|
|
int j=(-1);
|
|
char xor_val;
|
|
|
|
for (int i=0; i<en.length(); i++)
|
|
{
|
|
j = j + 1;
|
|
if (j >= clau.length()) j = 0;
|
|
xor_val = (char) ((int)en.charAt(i) ^ (int)clau.charAt(j));
|
|
// note: & 0xff is used to reset high bits
|
|
if ((xor_val>=0)&&(xor_val<=15)) sbRet.append("0"+Integer.toHexString(xor_val&0xff));
|
|
else sbRet.append(Integer.toHexString(xor_val&0xff));
|
|
}
|
|
m = sbRet.toString();
|
|
}
|
|
|
|
if (func.compareTo("XD") == 0)
|
|
{
|
|
// Desencriptar...
|
|
StringBuffer stringd=new StringBuffer(en.length()/2);
|
|
int j=(-1);
|
|
|
|
for (int i=0;i<en.length()/2;i++)
|
|
{
|
|
j = j + 1;
|
|
if (j >= clau.length()) j = 0;
|
|
if (en.substring(i*2,(i*2)+2).compareTo("ZZ") == 0) j = (-1);
|
|
else{
|
|
c=(char)(Integer.parseInt(en.substring(i*2,(i*2)+2),16)^(int)clau.charAt(j));
|
|
stringd.append(c);
|
|
}
|
|
}
|
|
m = stringd.toString();
|
|
}
|
|
return m;
|
|
}
|
|
|
|
%>
|
|
<%
|
|
/* PARAMETROS NECESARIOS PARA LA COMUNICACIÓN CON EL PROGRAMA INTRALAB INSTALADO EN LA 192.168.2.166 DE IZASA */
|
|
int campobusqueda=0;
|
|
String FiltroIntralab="";
|
|
String IntralabMaxReport="10";
|
|
String IntralabReportFormat="1";
|
|
String AccesLevel="8";
|
|
String TecnicalValidation="N";
|
|
|
|
String mydate="";
|
|
String mynumber=request.getParameter("peticion");
|
|
String mytipo="individual";
|
|
String isAcumulado="NO";
|
|
|
|
Socket miCliente;
|
|
DataInputStream entrada;
|
|
DataOutputStream salida;
|
|
String recibido,liniarecibida,liniasalida,aux;
|
|
Document document;
|
|
recibido=new String("");
|
|
|
|
try
|
|
{
|
|
/**** PETICIÓN POR EL NÚMERO PARA OBTENER LA FECHA DE REALIZACIÓN DE IZASA *******************************************/
|
|
/**** ABRIMOS DE NUEVO UN SOCKET PARA COMUNICACIÓN IZASA ***************************************************/
|
|
miCliente = new Socket ("192.168.2.166", 8080);
|
|
entrada = new DataInputStream(miCliente.getInputStream() );
|
|
salida = new DataOutputStream(miCliente.getOutputStream() );
|
|
liniasalida="<LIKENUMBER NUMBER='"+mynumber+"' FILTER='"+FiltroIntralab+"' USER='"+ "admin" + "' IPADDR='"+request.getRemoteAddr()+"' />";
|
|
salida.writeBytes(crypt_txt(liniasalida,"","XE"));
|
|
while (null != ((liniarecibida = crypt_txt(entrada.readLine(),"","XD"))))
|
|
{
|
|
recibido = recibido +liniarecibida+"\n";
|
|
}
|
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
|
document=builder.parse(new ByteArrayInputStream(recibido.getBytes()));
|
|
NodeList nl=document.getElementsByTagName("PATIENT");
|
|
if (nl.getLength()>0)
|
|
{
|
|
mydate = (String)nl.item(0).getAttributes().getNamedItem("DATE").getNodeValue();
|
|
}
|
|
entrada.close();
|
|
salida.close();
|
|
/**** FIN PETICIÓN POR EL NÚMERO PARA OBTENER LA FECHA DE REALIZACIÓN DE IZASA *******************************************/
|
|
|
|
/**** ABRIMOS DE NUEVO UN SOCKET PARA COMUNICACIÓN IZASA ***************************************************/
|
|
/**** INICIO PETICIÓN DEFINITIVA ****/
|
|
miCliente = new Socket ("192.168.2.166", 8080);
|
|
entrada = new DataInputStream(miCliente.getInputStream() );
|
|
salida = new DataOutputStream(miCliente.getOutputStream() );
|
|
liniasalida="<REPORT DATE='"+mydate+"' NUMBER='"+mynumber+"' ACCUMULATED='"+isAcumulado+"' USER='"+"admin"+"' MAXREPORT='"+IntralabMaxReport+"' FORMAT='"+IntralabReportFormat+"' ACCESLEVEL='"+AccesLevel+"' TECNICALVALIDATION='"+TecnicalValidation+"' FILTER='"+FiltroIntralab+"' IPADDR='"+request.getRemoteAddr()+"' />";
|
|
salida.writeBytes(crypt_txt(liniasalida,"","XE"));
|
|
while (null != ((liniarecibida = crypt_txt(entrada.readLine(),"","XD"))))
|
|
{
|
|
recibido = recibido +liniarecibida+"\n";
|
|
}
|
|
entrada.close();
|
|
salida.close();
|
|
if (recibido.compareTo("<ERROR='Error to Print'/>\n")==0)
|
|
{
|
|
response.sendRedirect("lab_informe_vacio.jsp");
|
|
return;
|
|
}
|
|
aux = recibido.replaceAll("á", "á");
|
|
aux = aux.replaceAll("é", "é");
|
|
aux = aux.replaceAll("í", "í");
|
|
aux = aux.replaceAll("ó", "ó");
|
|
aux = aux.replaceAll("ú", "ú");
|
|
aux = aux.replaceAll("º", "º");
|
|
out.println(aux);
|
|
}
|
|
catch( IOException e )
|
|
{
|
|
response.sendRedirect("pac/gestor.jsp");
|
|
return;
|
|
}
|
|
}
|
|
LogTarisan.logger.log(NivelLog.INFO, "Fin página de resultados analitica (resultado_analitica.jsp)");
|
|
%> |