(no commit message)
authormaroni <maroni@192.168.1.103>
Wed, 15 Feb 2012 13:29:35 +0000 (11:29 -0200)
committermaroni <maroni@192.168.1.103>
Wed, 15 Feb 2012 13:29:35 +0000 (11:29 -0200)
src/java/org/ufcspa/simdecs/comunicacao/MetodoIniciaCaso.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaCaso.java
src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaJogo.java [deleted file]
src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaTipoJogo.java [deleted file]
src/java/org/ufcspa/simdecs/entities/Log.java
src/java/org/ufcspa/simdecs/entities/TipoEventoLog.java
src/java/org/ufcspa/simdecs/mb/editarcasos/EditarCasoBean.java
web/WEB-INF/web.xml
web/editarcasos/editarCaso.xhtml

diff --git a/src/java/org/ufcspa/simdecs/comunicacao/MetodoIniciaCaso.java b/src/java/org/ufcspa/simdecs/comunicacao/MetodoIniciaCaso.java
new file mode 100644 (file)
index 0000000..7b11522
--- /dev/null
@@ -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 <PerguntaNodo> 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("<caso uid=\"caso-" + caso.getId() + "\" sessao=\"" + sessaoUsuario.getId() + "\" titulo=\"" + caso.getNome() + "\" modelo=\"" + caso.getModelo() + "\" descricaoAmbiente=\"" + caso.getTextoInicial() + "\">");
+
+            Iterator<Paciente> itPac = em.createQuery("From Paciente where caso.id=:pIdCaso")
+                                         .setParameter("pIdCaso", caso.getId())
+                                         .getResultList()
+                                         .iterator();
+            while(itPac.hasNext()) {
+                Paciente paciente = itPac.next();
+                out.println("    <ator uid=\"paciente-" + paciente.getId() + "\" tipo=\"paciente\" nome=\"" + paciente.getNome() + "\" modelo=\"" + paciente.getModelo() + "\" idade=\"" + paciente.getIdade() + "\" peso=\"" + paciente.getPeso() + "\" altura=\"" + paciente.getAltura() + "\" >");
+
+                out.println("        <etapa uid=\"etapa-1\" nome=\"Investigação\" sequencia=\"1\" tipo=\"investigacao\">");
+
+                // Sinais e sintomas
+                out.println("            <perguntar_sintoma uid=\"perguntar-sintoma-" + paciente.getId() + "\" descricao=\"Perguntar Sinais/Sintomas\">");                     
+                List<NodoPaciente> 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("                <sintoma uid=\"sintoma-" + nodo.getId() + "\" nomeCientifico=\"" + nodo.getNodo().getNome() + "\" nomePopular=\"" + nodo.getNodo().getNomeAmigavel() + "\" imagem=\"\" som=\"\" video=\"\" dependencia=\"" + getDependencia(nodo.getNodo().getId()) + "\" falaPaciente=\"" + getPerguntaNodo(nodo.getNodo().getId())  + "\">");
+                }
+                out.println("            </perguntar_sintoma>");
+
+                // Exame Físico
+                out.println("            <realiza_exame_fisico uid=\"realiza-exame-fisico-" + paciente.getId() + "\" descricao=\"Realizar Exame Físico\">");
+                for(NodoPaciente nodo : nodos) {
+                    if (!nodo.getNodo().getTipo().equals(Nodo.EXAME_FISICO))
+                        continue;
+                
+                    out.println("                <exame_fisico uid=\"exame-fisico-" + nodo.getId() + "\" dependencia=\"" + getDependencia(nodo.getNodo().getId()) + "\" descricao=\"" + nodo.getNodo().getNomeAmigavel() + "\" resultado=\"\" imagem=\"\" som=\"\" video=\"\">");
+                }
+                out.println("            </realiza_exame_fisico>");
+
+                // Exame Complementar
+                out.println("            <solicitar_exames_complementar uid=\"solicitar-exame-complementar-" + paciente.getId() + "\" descricao=\"Solicitar Exame Complementar\">\"");
+                for(NodoPaciente nodo : nodos) {
+                    if (!nodo.getNodo().getTipo().equals(Nodo.EXAME_COMPLEMENTAR))
+                        continue;
+                
+                    out.println("                <exame_complementar uid=\"exame-complementar-" + nodo.getId() + "\" dependencia=\"" + getDependencia(nodo.getNodo().getId()) + "\" descricao=\"" + nodo.getNodo().getNomeAmigavel() + "\" resultado=\"\" imagem=\"\" som=\"\" video=\"\">");
+                }
+                out.println("            </solicitar_exames_complementar>");
+
+                // historico
+                for(NodoPaciente nodo : nodos) {
+                    if (!nodo.getNodo().getTipo().equals(Nodo.HISTORICO))
+                        continue;
+                
+                    out.println("        <historico_medico uid=\"historico-medico-" + nodo.getId() + "\" dependencia=\"" + getDependencia(nodo.getNodo().getId()) + "\" descricao=\"Histórico Médico\" historico=\"" + nodo.getNodo().getNomeAmigavel() + "\" dependencia=\"\" imagem=\"\" som=\"\" video=\"\">");
+                }
+            
+            
+                out.println("        </etapa>");
+            
+                out.println("        <etapa uid=\"etapa-2\" nome=\"Diagnóstico\" sequencia=\"2\" tipo=\"diagnostico\">");
+                Iterator<Nodo> itDiagnosticos = em.createQuery("From Nodo where tipo=:pTipo")
+                                                  .setParameter("pTipo", Nodo.DIAGNOSTICO)
+                                                  .getResultList()
+                                                  .iterator();            
+                while(itDiagnosticos.hasNext()) {
+                    Nodo nodo = itDiagnosticos.next();
+                    out.println("            <diagnostico uid=\"diagnostico-" + nodo.getId() + "\" nome=\"" + nodo.getNomeAmigavel() + "\" />");
+                }
+                out.println("        </etapa>");
+            
+                out.println("        <etapa uid=\"etapa-3\" nome=\"Conduta\" sequencia=\"3\" tipo=\"conduta\">");
+                Iterator<Nodo> itConduta = em.createQuery("From Nodo where tipo=:pTipo")
+                                             .setParameter("pTipo", Nodo.CONDUTA)
+                                             .getResultList()
+                                             .iterator();            
+                while(itConduta.hasNext()) {
+                    Nodo nodo = itConduta.next();
+                    out.println("            <conduta uid=\"conduta-" + nodo.getId() + "\" nome=\"" + nodo.getNomeAmigavel() + "\" />");
+                }
+                out.println("        </etapa>");
+                out.println("    </ator>");
+        }
+       
+        
+        out.println("</caso>");
+        } finally {            
+            out.close();
+        }
+    }
+
+    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
+    /**
+     * Handles the HTTP
+     * <code>GET</code> 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
+     * <code>POST</code> 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";
+    }// </editor-fold>
+}
index d6d02fa..d5f0800 100644 (file)
@@ -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<Caso> it = em.createQuery("From Caso where usuario.id=:pIdUsuario")
-                              .setParameter("pIdUsuario", pIdUsuario)
-                              .getResultList()
-                              .iterator();
-        while(it.hasNext()) {
-            Caso caso = it.next();
-            out.println("   <caso id=\"" + caso.getId() + "\" titulo=\"" + caso.getNome() + "\" resumo=\"" + caso.getResumo() + "\" />");
+        try {
+            response.setContentType( "text/xml" );
+            response.setHeader( "Cache-Control", "no-cache" );
+
+            EntityManager em = DbUtil.getInstance().getEntityManager();
+            long pIdUsuario = Long.parseLong(request.getParameter("idusuario"));
+
+            Iterator<Caso> it = em.createQuery("From Caso where usuario.id=:pIdUsuario")
+                                .setParameter("pIdUsuario", pIdUsuario)
+                                .getResultList()
+                                .iterator();
+            out.println( "<xml>" );
+
+            while(it.hasNext()) {
+                Caso caso = it.next();
+                out.println("   <caso id=\"" + caso.getId() + "\" titulo=\"" + caso.getNome() + "\" resumo=\"" + caso.getResumo() + "\" />");
+            }
+
+            out.println( "</xml>" );
+        } finally {
+            out.close();
         }
         
-        out.println( "<xml>" );
-        out.println( "</xml>" );
     }
 
     // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
diff --git a/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaJogo.java b/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaJogo.java
deleted file mode 100644 (file)
index ec025e9..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/*\r
- * To change this template, choose Tools | Templates\r
- * and open the template in the editor.\r
- */\r
-package org.ufcspa.simdecs.comunicacao;\r
-\r
-import java.io.IOException;\r
-import javax.servlet.ServletException;\r
-import javax.servlet.http.HttpServlet;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-/**\r
- *\r
- * @author pbarros\r
- */\r
-public class MetodoSelecionaJogo extends HttpServlet {\r
-\r
-    /**\r
-     * Processes requests for both HTTP\r
-     * <code>GET</code> and\r
-     * <code>POST</code> methods.\r
-     *\r
-     * @param request servlet request\r
-     * @param response servlet response\r
-     * @throws ServletException if a servlet-specific error occurs\r
-     * @throws IOException if an I/O error occurs\r
-     */\r
-    protected void processRequest(HttpServletRequest request, HttpServletResponse response)\r
-            throws ServletException, IOException {\r
-/*        \r
-        PrintWriter out = response.getWriter();\r
-        // alteracao solicitado mosmmann \r
-        //response.setContentType("text/html;charset=UTF-8");\r
-        \r
-        response.setContentType( "text/xml" );\r
-        response.setHeader( "Cache-Control", "no-cache" );\r
-        ///para devolver arquivo anexo\r
-        //response.addHeader("Content-Disposition", "attachment; filename="+ "teste");\r
-      \r
-        \r
-        EntityManagerFactory emf = Persistence.createEntityManagerFactory("simdecsPU");\r
-        EntityManager em = emf.createEntityManager();\r
-        \r
-        out.println( "<xml>" );\r
-        \r
-        \r
-        List<ArquivoCaso> arquivos;\r
-        try {\r
-            \r
-            if(request.getParameter("Tipo").trim().equals("Medicina"))\r
-            {\r
-                arquivos =  em.createQuery("select arq from ArquivoCaso as arq ").getResultList();\r
-                if(arquivos.isEmpty())\r
-                {\r
-                    out.println( "<game>" );\r
-                    out.println( "<titulo>" + "Nenhuma rede disponível" + "</titulo>" );\r
-                    out.println( "<descricao>" + "Nenhuma rede disponível" + "</descricao>" );\r
-                    out.println( "<id>" + "0" + "</id>" );\r
-                    out.println( "</game>" );\r
-                }\r
-                else\r
-                {\r
-                    StringBuffer arqBuffer = new StringBuffer();\r
-                    for (ArquivoCaso arq : arquivos ) {  \r
-                    //List selecionavel = new ArrayList();\r
-                        \r
-                        out.println( "<game>" );\r
-                        out.println( "<titulo>" + arq.getNome() + "</titulo>" );\r
-                        out.println( "<descricao>" + arq.getNome() + "</descricao>" );\r
-                        out.println( "<id>" + String.valueOf(arq.getId()) + "</id>" );\r
-                        out.println( "</game>" );\r
-                    }\r
-                    //request.setAttribute("rede", arqBuffer);\r
-                    //out.println(arqBuffer.toString());\r
-                    \r
-                    \r
-                }\r
-            }\r
-            else\r
-            {\r
-                out.println( "<rede>" + "Tipo Inválido" + "</rede>" );\r
-                out.println( "<idRede>" + "0" + "</idRede>" );\r
-                \r
-            }\r
-        } finally {         \r
-            out.println( "</xml>" );\r
-            out.close();\r
-        }\r
-*/\r
- }\r
-\r
-    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">\r
-    /**\r
-     * Handles the HTTP\r
-     * <code>GET</code> method.\r
-     *\r
-     * @param request servlet request\r
-     * @param response servlet response\r
-     * @throws ServletException if a servlet-specific error occurs\r
-     * @throws IOException if an I/O error occurs\r
-     */\r
-    @Override\r
-    protected void doGet(HttpServletRequest request, HttpServletResponse response)\r
-            throws ServletException, IOException {\r
-        processRequest(request, response);\r
-        \r
-        \r
-        \r
-        \r
-    }\r
-\r
-    /**\r
-     * Handles the HTTP\r
-     * <code>POST</code> method.\r
-     *\r
-     * @param request servlet request\r
-     * @param response servlet response\r
-     * @throws ServletException if a servlet-specific error occurs\r
-     * @throws IOException if an I/O error occurs\r
-     */\r
-    @Override\r
-    protected void doPost(HttpServletRequest request, HttpServletResponse response)\r
-            throws ServletException, IOException {\r
-        processRequest(request, response);\r
-    }\r
-\r
-    /**\r
-     * Returns a short description of the servlet.\r
-     *\r
-     * @return a String containing servlet description\r
-     */\r
-    @Override\r
-    public String getServletInfo() {\r
-        return "Short description";\r
-    }// </editor-fold>\r
-}\r
diff --git a/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaTipoJogo.java b/src/java/org/ufcspa/simdecs/comunicacao/MetodoSelecionaTipoJogo.java
deleted file mode 100644 (file)
index b1264b2..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*\r
- * To change this template, choose Tools | Templates\r
- * and open the template in the editor.\r
- */\r
-package org.ufcspa.simdecs.comunicacao;\r
-\r
-import java.io.IOException;\r
-import java.io.PrintWriter;\r
-import javax.servlet.ServletException;\r
-import javax.servlet.http.HttpServlet;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-/**\r
- *\r
- * @author pbarros\r
- */\r
-public class MetodoSelecionaTipoJogo extends HttpServlet {\r
-\r
-    /**\r
-     * Processes requests for both HTTP\r
-     * <code>GET</code> and\r
-     * <code>POST</code> methods.\r
-     *\r
-     * @param request servlet request\r
-     * @param response servlet response\r
-     * @throws ServletException if a servlet-specific error occurs\r
-     * @throws IOException if an I/O error occurs\r
-     */\r
-    protected void processRequest(HttpServletRequest request, HttpServletResponse response)\r
-            throws ServletException, IOException {\r
-//        response.setContentType("text/html;charset=UTF-8");\r
-//        PrintWriter out = response.getWriter();\r
-        PrintWriter out = response.getWriter();\r
-        // alteracao solicitado mosmmann \r
-        //response.setContentType("text/html;charset=UTF-8");\r
-        \r
-        response.setContentType( "text/xml" );\r
-        response.setHeader( "Cache-Control", "no-cache" );\r
-        ///para devolver arquivo anexo\r
-        //response.addHeader("Content-Disposition", "attachment; filename="+ "teste");\r
-        //response.setContentType("text/html;charset=UTF-8");\r
-                out.println( "<xml>" );\r
-        try {\r
-            /*\r
-             * TODO output your page here. You may use following sample code.\r
-             */\r
-//            request.setAttribute("Tipo", "Medicina");\r
-//            out.print("Medicina");\r
-            out.println( "<Tipo>" + "Medicina" + "</Tipo>" );\r
-\r
-        } finally {     \r
-            out.println( "</xml>" );\r
-            out.close();\r
-        }\r
-    }\r
-\r
-    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">\r
-    /**\r
-     * Handles the HTTP\r
-     * <code>GET</code> method.\r
-     *\r
-     * @param request servlet request\r
-     * @param response servlet response\r
-     * @throws ServletException if a servlet-specific error occurs\r
-     * @throws IOException if an I/O error occurs\r
-     */\r
-    @Override\r
-    protected void doGet(HttpServletRequest request, HttpServletResponse response)\r
-            throws ServletException, IOException {\r
-        processRequest(request, response);\r
-    }\r
-\r
-    /**\r
-     * Handles the HTTP\r
-     * <code>POST</code> method.\r
-     *\r
-     * @param request servlet request\r
-     * @param response servlet response\r
-     * @throws ServletException if a servlet-specific error occurs\r
-     * @throws IOException if an I/O error occurs\r
-     */\r
-    @Override\r
-    protected void doPost(HttpServletRequest request, HttpServletResponse response)\r
-            throws ServletException, IOException {\r
-        processRequest(request, response);\r
-    }\r
-\r
-    /**\r
-     * Returns a short description of the servlet.\r
-     *\r
-     * @return a String containing servlet description\r
-     */\r
-    @Override\r
-    public String getServletInfo() {\r
-        return "Short description";\r
-    }// </editor-fold>\r
-}\r
index 1e3bcf7..a23291c 100644 (file)
@@ -55,6 +55,22 @@ public class Log implements Serializable {
     @Column(name = "descricao")\r
     private String descricao;\r
 \r
+    public Log(Date data, TipoEventoLog tipo, SessaoUsuario sessaoUsuario, Caso caso, Paciente paciente, Nodo nodo, Rede rede, String descricao) {\r
+        this.data = data;\r
+        this.tipo = tipo;\r
+        this.sessaoUsuario = sessaoUsuario;\r
+        this.caso = caso;\r
+        this.paciente = paciente;\r
+        this.nodo = nodo;\r
+        this.rede = rede;\r
+        this.descricao = descricao;\r
+    }\r
+\r
+    public Log() {\r
+    }\r
+\r
+    \r
+    \r
     public Caso getCaso() {\r
         return caso;\r
     }\r
index f9b0a7d..6129264 100644 (file)
@@ -6,8 +6,6 @@ package org.ufcspa.simdecs.entities;
 \r
 import java.io.Serializable;\r
 import javax.persistence.*;\r
-import javax.validation.constraints.NotNull;\r
-import javax.validation.constraints.Size;\r
 \r
 /**\r
  *\r
@@ -18,8 +16,8 @@ import javax.validation.constraints.Size;
 public class TipoEventoLog implements Serializable {\r
     private static final long serialVersionUID = 1L;\r
     \r
-    @SequenceGenerator(name="seqTipEveLog", sequenceName="SQTPEVLG")\r
-    @GeneratedValue(strategy=GenerationType.AUTO, generator="seqTipEveLog")\r
+    public static String INICIO_CASO = "INICIO_CASO";\r
+    \r
     @Id\r
     private String id;\r
     \r
index bbbbfeb..c3217a9 100644 (file)
@@ -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("<caso uid=\"caso-" + caso.getId() + "\" titulo=\"" + caso.getNome() + "\" modelo=\"" + caso.getModelo() + "\" descricaoAmbiente=\"" + caso.getTextoInicial() + "\">\n");
-
-        Iterator<Paciente> itPac = em.createQuery("From Paciente where caso.id=:pIdCaso")
-                                     .setParameter("pIdCaso", caso.getId())
-                                     .getResultList()
-                                     .iterator();
-        while(itPac.hasNext()) {
-            Paciente paciente = itPac.next();
-            str.append("    <ator uid=\"paciente-" + paciente.getId() + "\" tipo=\"paciente\" nome=\"" + paciente.getNome() + "\" modelo=\"" + paciente.getModelo() + "\" idade=\"" + paciente.getIdade() + "\" peso=\"" + paciente.getPeso() + "\" altura=\"" + paciente.getAltura() + "\" >\n");
-
-            str.append("        <etapa uid=\"etapa-1\" nome=\"Investigação\" sequencia=\"1\" tipo=\"investigacao\">\n");
-
-            // Sinais e sintomas
-            str.append("            <perguntar_sintoma uid=\"perguntar-sintoma-" + paciente.getId() + "\" descricao=\"Perguntar Sinais/Sintomas\">\n");                        
-            List<NodoPaciente> 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("                <sintoma uid=\"sintoma-" + nodo.getId() + "\" nomeCientifico=\"" + nodo.getNodo().getNome() + "\" nomePopular=\"" + nodo.getNodo().getNomeAmigavel() + "\" imagem=\"\" som=\"\" video=\"\" dependencia=\"" + getDependencia(nodo.getNodo().getId()) + "\" falaPaciente=\"" + getPerguntaNodo(nodo.getNodo().getId())  + "\">\n");
-            }
-            str.append("            </perguntar_sintoma>\n");
-
-            // Exame Físico
-            str.append("            <realiza_exame_fisico uid=\"realiza-exame-fisico-" + paciente.getId() + "\" descricao=\"Realizar Exame Físico\">\n");                     
-            for(NodoPaciente nodo : nodos) {
-                if (!nodo.getNodo().getTipo().equals(Nodo.EXAME_FISICO))
-                    continue;
-                
-                str.append("                <exame_fisico uid=\"exame-fisico-" + nodo.getId() + "\" dependencia=\"" + getDependencia(nodo.getNodo().getId()) + "\" descricao=\"" + nodo.getNodo().getNomeAmigavel() + "\" resultado=\"\" imagem=\"\" som=\"\" video=\"\">\n");
-            }
-            str.append("            </realiza_exame_fisico>\n");
-
-            // Exame Complementar
-            str.append("            <solicitar_exames_complementar uid=\"solicitar-exame-complementar-" + paciente.getId() + "\" descricao=\"Solicitar Exame Complementar\">\n");                      
-            for(NodoPaciente nodo : nodos) {
-                if (!nodo.getNodo().getTipo().equals(Nodo.EXAME_COMPLEMENTAR))
-                    continue;
-                
-                str.append("                <exame_complementar uid=\"exame-complementar-" + nodo.getId() + "\" dependencia=\"" + getDependencia(nodo.getNodo().getId()) + "\" descricao=\"" + nodo.getNodo().getNomeAmigavel() + "\" resultado=\"\" imagem=\"\" som=\"\" video=\"\">\n");
-            }
-            str.append("            </solicitar_exames_complementar>\n");
-
-            // historico
-            for(NodoPaciente nodo : nodos) {
-                if (!nodo.getNodo().getTipo().equals(Nodo.HISTORICO))
-                    continue;
-                
-                str.append("        <historico_medico uid=\"historico-medico-" + nodo.getId() + "\" dependencia=\"" + getDependencia(nodo.getNodo().getId()) + "\" descricao=\"Histórico Médico\" historico=\"" + nodo.getNodo().getNomeAmigavel() + "\" dependencia=\"\" imagem=\"\" som=\"\" video=\"\">\n");
-            }
-            
-            
-            str.append("        </etapa>\n");
-            
-            str.append("        <etapa uid=\"etapa-2\" nome=\"Diagnóstico\" sequencia=\"2\" tipo=\"diagnostico\">\n");           
-            Iterator<Nodo> itDiagnosticos = em.createQuery("From Nodo where tipo=:pTipo")
-                                              .setParameter("pTipo", Nodo.DIAGNOSTICO)
-                                              .getResultList()
-                                              .iterator();            
-            while(itDiagnosticos.hasNext()) {
-                Nodo nodo = itDiagnosticos.next();
-                str.append("            <diagnostico uid=\"diagnostico-" + nodo.getId() + "\" nome=\"" + nodo.getNomeAmigavel() + "\" />\n");
-            }
-            str.append("        </etapa>\n");
-            
-            str.append("        <etapa uid=\"etapa-3\" nome=\"Conduta\" sequencia=\"3\" tipo=\"conduta\">\n");           
-            Iterator<Nodo> itConduta = em.createQuery("From Nodo where tipo=:pTipo")
-                                              .setParameter("pTipo", Nodo.CONDUTA)
-                                              .getResultList()
-                                              .iterator();            
-            while(itConduta.hasNext()) {
-                Nodo nodo = itConduta.next();
-                str.append("            <conduta uid=\"conduta-" + nodo.getId() + "\" nome=\"" + nodo.getNomeAmigavel() + "\" />\n");
-            }
-            str.append("        </etapa>\n");
-            
-                   
-            str.append("    </ator>\n");
-            
-        }
-       
-        
-        str.append("</caso>\n");
-        xml = str.toString();
-        addInfoMessage("Arquivo gerado!", "XML gerado com sucesso!");        
-    }
-    
+       
     public void adicionarPaciente() {
         Rede rede = em.find(Rede.class, redePaciente);
         em.getTransaction().begin();
index e7beb95..1c8cfe6 100644 (file)
         <servlet-name>MetodoSelecionaCaso</servlet-name>
         <servlet-class>org.ufcspa.simdecs.comunicacao.MetodoSelecionaCaso</servlet-class>
     </servlet>
+    <servlet>
+        <servlet-name>MetodoIniciaCaso</servlet-name>
+        <servlet-class>org.ufcspa.simdecs.comunicacao.MetodoIniciaCaso</servlet-class>
+    </servlet>
     <servlet-mapping>
         <servlet-name>Faces Servlet</servlet-name>
         <url-pattern>*.jsf</url-pattern>
         <servlet-name>MetodoSelecionaCaso</servlet-name>
         <url-pattern>/MetodoSelecionaCaso</url-pattern>
     </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>MetodoIniciaCaso</servlet-name>
+        <url-pattern>/MetodoIniciaCaso</url-pattern>
+    </servlet-mapping>
     <session-config>
         <session-timeout>
             30
index 07063b1..47b6b0a 100644 (file)
                     </tr>
                 </table>
                 <br/><br/>
-                <p:inputTextarea id="xmlText" value="#{editarCasoBean.xml}" rows="18" autoResize="false" cols="200"/>
-                <br/>
-                <p:commandButton id="gerarXML" update="xmlText, messageGrow"  action="#{editarCasoBean.gerarXML()}" value="Gerar XML" />
-                 &nbsp;&nbsp;&nbsp;
                  <p:commandButton id="voltar" value="Voltar" immediate="true" action="#{editarCasoBean.voltar()}" />
                 <br/>
             </h:form>