From: maroni Date: Wed, 15 Feb 2012 13:29:35 +0000 (-0200) Subject: (no commit message) X-Git-Url: http://200.18.67.61/gitweb/?a=commitdiff_plain;h=ad3ad9f695f0703723000ec9f1335d2d1a05ddb2;p=simdecs2.git --- diff --git a/src/java/org/ufcspa/simdecs/comunicacao/MetodoIniciaCaso.java b/src/java/org/ufcspa/simdecs/comunicacao/MetodoIniciaCaso.java new file mode 100644 index 0000000..7b11522 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/comunicacao/MetodoIniciaCaso.java @@ -0,0 +1,204 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.ufcspa.simdecs.comunicacao; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import javax.persistence.EntityManager; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.xml.crypto.Data; +import org.ufcspa.simdecs.entities.*; +import org.ufcspa.simdecs.util.DbUtil; + +/** + * + * @author maroni + */ +public class MetodoIniciaCaso extends HttpServlet { + + private String getPerguntaNodo(Long idNodo) { + EntityManager em = DbUtil.getInstance().getEntityManager(); + List perguntas = em.createQuery("From PerguntaNodo where nodo.id=:pIdNodo") + .setParameter("pIdNodo", idNodo) + .getResultList(); + + int random = (int) (1+Math.random()*perguntas.size()); + int i=1; + + for(PerguntaNodo pergunta : perguntas) { + if (i++ == random) + return pergunta.getTexto(); + } + + return ""; + } + + private String getDependencia(Long idNodo) { + return ""; + } + + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + PrintWriter out = response.getWriter(); + try { + EntityManager em = DbUtil.getInstance().getEntityManager(); + Caso caso = em.find(Caso.class, Long.parseLong(request.getParameter("idcaso"))); + + + em.getTransaction().begin(); + + // Cria sessao + SessaoUsuario sessaoUsuario = new SessaoUsuario(); + sessaoUsuario.setData(new Date()); + sessaoUsuario.setUsuario(caso.getUsuario()); + em.persist(sessaoUsuario); + + // Logo inicio do caso + Log log = new Log(); + log.setTipo(em.find(TipoEventoLog.class, TipoEventoLog.INICIO_CASO)); + log.setCaso(caso); + log.setData(new Date()); + log.setSessaoUsuario(sessaoUsuario); + + em.persist(log); + + + em.getTransaction().commit(); + + out.println(""); + + Iterator itPac = em.createQuery("From Paciente where caso.id=:pIdCaso") + .setParameter("pIdCaso", caso.getId()) + .getResultList() + .iterator(); + while(itPac.hasNext()) { + Paciente paciente = itPac.next(); + out.println(" "); + + out.println(" "); + + // Sinais e sintomas + out.println(" "); + List nodos = em.createQuery("From NodoPaciente Where paciente.id=:pIDPaciente") + .setParameter("pIDPaciente", paciente.getId()) + .getResultList(); + for(NodoPaciente nodo : nodos) { + if (!nodo.getNodo().getTipo().equals(Nodo.SINAL_SINTOMA)) + continue; + + out.println(" "); + } + out.println(" "); + + // Exame Físico + out.println(" "); + for(NodoPaciente nodo : nodos) { + if (!nodo.getNodo().getTipo().equals(Nodo.EXAME_FISICO)) + continue; + + out.println(" "); + } + out.println(" "); + + // Exame Complementar + out.println(" \""); + for(NodoPaciente nodo : nodos) { + if (!nodo.getNodo().getTipo().equals(Nodo.EXAME_COMPLEMENTAR)) + continue; + + out.println(" "); + } + out.println(" "); + + // historico + for(NodoPaciente nodo : nodos) { + if (!nodo.getNodo().getTipo().equals(Nodo.HISTORICO)) + continue; + + out.println(" "); + } + + + out.println(" "); + + out.println(" "); + Iterator itDiagnosticos = em.createQuery("From Nodo where tipo=:pTipo") + .setParameter("pTipo", Nodo.DIAGNOSTICO) + .getResultList() + .iterator(); + while(itDiagnosticos.hasNext()) { + Nodo nodo = itDiagnosticos.next(); + out.println(" "); + } + out.println(" "); + + out.println(" "); + Iterator itConduta = em.createQuery("From Nodo where tipo=:pTipo") + .setParameter("pTipo", Nodo.CONDUTA) + .getResultList() + .iterator(); + while(itConduta.hasNext()) { + Nodo nodo = itConduta.next(); + out.println(" "); + } + out.println(" "); + out.println(" "); + } + + + out.println(""); + } finally { + out.close(); + } + } + + // + /** + * Handles the HTTP + * GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Handles the HTTP + * POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaCaso.java b/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaCaso.java index d6d02fa..d5f0800 100644 --- a/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaCaso.java +++ b/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaCaso.java @@ -35,24 +35,29 @@ public class MetodoSelecionaCaso extends HttpServlet { throws ServletException, IOException { PrintWriter out = response.getWriter(); - - response.setContentType( "text/xml" ); - response.setHeader( "Cache-Control", "no-cache" ); - - EntityManager em = DbUtil.getInstance().getEntityManager(); - long pIdUsuario = Long.parseLong(request.getParameter("idusuario")); - - Iterator it = em.createQuery("From Caso where usuario.id=:pIdUsuario") - .setParameter("pIdUsuario", pIdUsuario) - .getResultList() - .iterator(); - while(it.hasNext()) { - Caso caso = it.next(); - out.println(" "); + try { + response.setContentType( "text/xml" ); + response.setHeader( "Cache-Control", "no-cache" ); + + EntityManager em = DbUtil.getInstance().getEntityManager(); + long pIdUsuario = Long.parseLong(request.getParameter("idusuario")); + + Iterator it = em.createQuery("From Caso where usuario.id=:pIdUsuario") + .setParameter("pIdUsuario", pIdUsuario) + .getResultList() + .iterator(); + out.println( "" ); + + while(it.hasNext()) { + Caso caso = it.next(); + out.println(" "); + } + + out.println( "" ); + } finally { + out.close(); } - out.println( "" ); - out.println( "" ); } // diff --git a/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaJogo.java b/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaJogo.java deleted file mode 100644 index ec025e9..0000000 --- a/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaJogo.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.ufcspa.simdecs.comunicacao; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author pbarros - */ -public class MetodoSelecionaJogo extends HttpServlet { - - /** - * Processes requests for both HTTP - * GET and - * POST methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - protected void processRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { -/* - PrintWriter out = response.getWriter(); - // alteracao solicitado mosmmann - //response.setContentType("text/html;charset=UTF-8"); - - response.setContentType( "text/xml" ); - response.setHeader( "Cache-Control", "no-cache" ); - ///para devolver arquivo anexo - //response.addHeader("Content-Disposition", "attachment; filename="+ "teste"); - - - EntityManagerFactory emf = Persistence.createEntityManagerFactory("simdecsPU"); - EntityManager em = emf.createEntityManager(); - - out.println( "" ); - - - List arquivos; - try { - - if(request.getParameter("Tipo").trim().equals("Medicina")) - { - arquivos = em.createQuery("select arq from ArquivoCaso as arq ").getResultList(); - if(arquivos.isEmpty()) - { - out.println( "" ); - out.println( "" + "Nenhuma rede disponível" + "" ); - out.println( "" + "Nenhuma rede disponível" + "" ); - out.println( "" + "0" + "" ); - out.println( "" ); - } - else - { - StringBuffer arqBuffer = new StringBuffer(); - for (ArquivoCaso arq : arquivos ) { - //List selecionavel = new ArrayList(); - - out.println( "" ); - out.println( "" + arq.getNome() + "" ); - out.println( "" + arq.getNome() + "" ); - out.println( "" + String.valueOf(arq.getId()) + "" ); - out.println( "" ); - } - //request.setAttribute("rede", arqBuffer); - //out.println(arqBuffer.toString()); - - - } - } - else - { - out.println( "" + "Tipo Inválido" + "" ); - out.println( "" + "0" + "" ); - - } - } finally { - out.println( "" ); - out.close(); - } -*/ - } - - // - /** - * Handles the HTTP - * GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - - - - - } - - /** - * Handles the HTTP - * POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// -} diff --git a/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaTipoJogo.java b/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaTipoJogo.java deleted file mode 100644 index b1264b2..0000000 --- a/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaTipoJogo.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.ufcspa.simdecs.comunicacao; - -import java.io.IOException; -import java.io.PrintWriter; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author pbarros - */ -public class MetodoSelecionaTipoJogo extends HttpServlet { - - /** - * Processes requests for both HTTP - * GET and - * POST methods. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - protected void processRequest(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { -// response.setContentType("text/html;charset=UTF-8"); -// PrintWriter out = response.getWriter(); - PrintWriter out = response.getWriter(); - // alteracao solicitado mosmmann - //response.setContentType("text/html;charset=UTF-8"); - - response.setContentType( "text/xml" ); - response.setHeader( "Cache-Control", "no-cache" ); - ///para devolver arquivo anexo - //response.addHeader("Content-Disposition", "attachment; filename="+ "teste"); - //response.setContentType("text/html;charset=UTF-8"); - out.println( "" ); - try { - /* - * TODO output your page here. You may use following sample code. - */ -// request.setAttribute("Tipo", "Medicina"); -// out.print("Medicina"); - out.println( "" + "Medicina" + "" ); - - } finally { - out.println( "" ); - out.close(); - } - } - - // - /** - * Handles the HTTP - * GET method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Handles the HTTP - * POST method. - * - * @param request servlet request - * @param response servlet response - * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs - */ - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - processRequest(request, response); - } - - /** - * Returns a short description of the servlet. - * - * @return a String containing servlet description - */ - @Override - public String getServletInfo() { - return "Short description"; - }// -} diff --git a/src/java/org/ufcspa/simdecs/entities/Log.java b/src/java/org/ufcspa/simdecs/entities/Log.java index 1e3bcf7..a23291c 100644 --- a/src/java/org/ufcspa/simdecs/entities/Log.java +++ b/src/java/org/ufcspa/simdecs/entities/Log.java @@ -55,6 +55,22 @@ public class Log implements Serializable { @Column(name = "descricao") private String descricao; + public Log(Date data, TipoEventoLog tipo, SessaoUsuario sessaoUsuario, Caso caso, Paciente paciente, Nodo nodo, Rede rede, String descricao) { + this.data = data; + this.tipo = tipo; + this.sessaoUsuario = sessaoUsuario; + this.caso = caso; + this.paciente = paciente; + this.nodo = nodo; + this.rede = rede; + this.descricao = descricao; + } + + public Log() { + } + + + public Caso getCaso() { return caso; } diff --git a/src/java/org/ufcspa/simdecs/entities/TipoEventoLog.java b/src/java/org/ufcspa/simdecs/entities/TipoEventoLog.java index f9b0a7d..6129264 100644 --- a/src/java/org/ufcspa/simdecs/entities/TipoEventoLog.java +++ b/src/java/org/ufcspa/simdecs/entities/TipoEventoLog.java @@ -6,8 +6,6 @@ package org.ufcspa.simdecs.entities; import java.io.Serializable; import javax.persistence.*; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; /** * @@ -18,8 +16,8 @@ import javax.validation.constraints.Size; public class TipoEventoLog implements Serializable { private static final long serialVersionUID = 1L; - @SequenceGenerator(name="seqTipEveLog", sequenceName="SQTPEVLG") - @GeneratedValue(strategy=GenerationType.AUTO, generator="seqTipEveLog") + public static String INICIO_CASO = "INICIO_CASO"; + @Id private String id; diff --git a/src/java/org/ufcspa/simdecs/mb/editarcasos/EditarCasoBean.java b/src/java/org/ufcspa/simdecs/mb/editarcasos/EditarCasoBean.java index bbbbfeb..c3217a9 100644 --- a/src/java/org/ufcspa/simdecs/mb/editarcasos/EditarCasoBean.java +++ b/src/java/org/ufcspa/simdecs/mb/editarcasos/EditarCasoBean.java @@ -263,98 +263,7 @@ public class EditarCasoBean extends DefaultManagedBean { private String getDependencia(Long idNodo) { return ""; } - - public void gerarXML() throws IOException { - StringBuilder str = new StringBuilder(); - str.append("\n"); - - Iterator itPac = em.createQuery("From Paciente where caso.id=:pIdCaso") - .setParameter("pIdCaso", caso.getId()) - .getResultList() - .iterator(); - while(itPac.hasNext()) { - Paciente paciente = itPac.next(); - str.append(" \n"); - - str.append(" \n"); - - // Sinais e sintomas - str.append(" \n"); - List nodos = em.createQuery("From NodoPaciente Where paciente.id=:pIDPaciente") - .setParameter("pIDPaciente", paciente.getId()) - .getResultList(); - for(NodoPaciente nodo : nodos) { - if (!nodo.getNodo().getTipo().equals(Nodo.SINAL_SINTOMA)) - continue; - - str.append(" \n"); - } - str.append(" \n"); - - // Exame Físico - str.append(" \n"); - for(NodoPaciente nodo : nodos) { - if (!nodo.getNodo().getTipo().equals(Nodo.EXAME_FISICO)) - continue; - - str.append(" \n"); - } - str.append(" \n"); - - // Exame Complementar - str.append(" \n"); - for(NodoPaciente nodo : nodos) { - if (!nodo.getNodo().getTipo().equals(Nodo.EXAME_COMPLEMENTAR)) - continue; - - str.append(" \n"); - } - str.append(" \n"); - - // historico - for(NodoPaciente nodo : nodos) { - if (!nodo.getNodo().getTipo().equals(Nodo.HISTORICO)) - continue; - - str.append(" \n"); - } - - - str.append(" \n"); - - str.append(" \n"); - Iterator itDiagnosticos = em.createQuery("From Nodo where tipo=:pTipo") - .setParameter("pTipo", Nodo.DIAGNOSTICO) - .getResultList() - .iterator(); - while(itDiagnosticos.hasNext()) { - Nodo nodo = itDiagnosticos.next(); - str.append(" \n"); - } - str.append(" \n"); - - str.append(" \n"); - Iterator itConduta = em.createQuery("From Nodo where tipo=:pTipo") - .setParameter("pTipo", Nodo.CONDUTA) - .getResultList() - .iterator(); - while(itConduta.hasNext()) { - Nodo nodo = itConduta.next(); - str.append(" \n"); - } - str.append(" \n"); - - - str.append(" \n"); - - } - - - str.append("\n"); - xml = str.toString(); - addInfoMessage("Arquivo gerado!", "XML gerado com sucesso!"); - } - + public void adicionarPaciente() { Rede rede = em.find(Rede.class, redePaciente); em.getTransaction().begin(); diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index e7beb95..1c8cfe6 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -17,6 +17,10 @@ MetodoSelecionaCaso org.ufcspa.simdecs.comunicacao.MetodoSelecionaCaso + + MetodoIniciaCaso + org.ufcspa.simdecs.comunicacao.MetodoIniciaCaso + Faces Servlet *.jsf @@ -29,6 +33,10 @@ MetodoSelecionaCaso /MetodoSelecionaCaso + + MetodoIniciaCaso + /MetodoIniciaCaso + 30 diff --git a/web/editarcasos/editarCaso.xhtml b/web/editarcasos/editarCaso.xhtml index 07063b1..47b6b0a 100644 --- a/web/editarcasos/editarCaso.xhtml +++ b/web/editarcasos/editarCaso.xhtml @@ -49,10 +49,6 @@

- -
- -