Package healthwatcher.model.complaint

Examples of healthwatcher.model.complaint.DiseaseType


  }

  public void execute() throws Exception {
    PrintWriter out = response.getWriter();
   
    DiseaseType diseaseType = null;
      
        try {
       
            if (! request.isAuthorized()) {
                throw new InvalidSessionException();
            }           

      String code = request.getInput("code");
      String name = request.getInput("name");
      String description = request.getInput("description");
      String manifestacao = request.getInput("manifestacao");
      String duration = request.getInput("duration");
     
      // TODO: FALTA INCLUIR OS SINTOMAS JUNTOS
      diseaseType = new DiseaseType(name, description, manifestacao, duration, null);
      //#if relacional
      diseaseType.setId(Long.parseLong(code));
      //#endif
      //#if norelacional
//@      diseaseType.setCode(Integer.parseInt(code));
      //#endif
     
View Full Code Here


    Long codigoTipoDoenca = Long.parseLong(request
        .getInput("codTipoDoenca"));
   
    System.out.println(codigoTipoDoenca);
    try {
      DiseaseType tp = facade.searchDiseaseType(codigoTipoDoenca);
      System.out.println("Descricao: "+tp.getDescription());
     
      out.println(HTMLCode.open("Queries - Diseases"));
      out.println("<body><h1>Querie result<br>Disease</h1>");

      out.println("<P><h3>Name: " + tp.getName() + "</h3></P>");
      out.println("<P>Description: " + tp.getDescription() + "</P>");
      out.println("<P>How manifests: " + tp.getManifestation() + " </P>");
      out.println("<P>Duration: " + tp.getDuration() + " </P>");
      out.println("<P>Symptoms: </P>");

      Iterator i = tp.getSymptoms().iterator();

      if (!i.hasNext()) {
        out.println("<P>There isn't registered symptoms.</P>");
      } else {
        while (i.hasNext()) {
View Full Code Here

      if (!rs.next()) {
        throw new ObjectNotFoundException(ExceptionMessages.EXC_FALHA_PROCURA);
      }

      do {
        DiseaseType td = partialSearch((new Long(rs.getString("codigo"))).longValue());
        listatd.add(td);
      } while (rs.next());

      rs.close();
      stmt.close();
View Full Code Here

   */
  public DiseaseType partialSearch(Long codigo) throws ObjectNotFoundException, RepositoryException {

    System.out.println("RepositorioTipoDoenca::procuraParcial()->begin");

    DiseaseType td = null;
    String nome, descricao, manifestacao, duracao;
    String sql = null;
    // Tentativa de recuperar os dados do bd usando o c�digo
    // informado
    try {
      sql = "select * from scbs_tipodoenca where " + "codigo = '" + codigo + "'";

      Statement stmt = (Statement) this.mp.getCommunicationChannel();
      resultSet = stmt.executeQuery(sql);

      if (resultSet.next()) {
        codigo = (new Long(resultSet.getString("codigo"))).longValue();
        nome = resultSet.getString("nome");
        descricao = resultSet.getString("descricao");
        manifestacao = resultSet.getString("manifestacao");
        duracao = resultSet.getString("duracao");

        //preparar para buscar em outra tabela os sintomas desta doenca
        //depois vai chamar deepAccess() de SymptomRepositoryArray
      } else {
        throw new ObjectNotFoundException(ExceptionMessages.EXC_FALHA_PROCURA);
      }
      resultSet.close();
      stmt.close();

      td = new DiseaseType();
      td.setName(nome);
      td.setDescription(descricao);
      td.setManifestation(manifestacao);
      td.setDuration(duracao);
      td.setId(codigo);

    } catch (PersistenceMechanismException e) {
      throw new RepositoryException(e.getMessage());
    } catch (SQLException e) {
      throw new SQLPersistenceMechanismException(e.getMessage(),sql);
View Full Code Here

   * @return um objeto tipo doen�a montado a partir dos dados
   *       do banco de dados
   */
  public DiseaseType search(Long code) throws RepositoryException, ObjectNotFoundException {

    DiseaseType td = null;
    String nome, descricao, manifestacao, duracao;
    List sintomas;
    String sql = null;
    // Tentativa de recuperar os dados do bd usando o c�digo
    // informado
    try {
      sql = "select * from scbs_tipodoenca where " + "codigo = '" + code + "'";

      Statement stmt = (Statement) this.mp.getCommunicationChannel();
      resultSet = stmt.executeQuery(sql);

      if (resultSet.next()) {
        code = (new Long(resultSet.getString("codigo"))).longValue();
        nome = resultSet.getString("nome");
        descricao = resultSet.getString("descricao");
        manifestacao = resultSet.getString("manifestacao");
        duracao = resultSet.getString("duracao");

        //preparar para buscar em outra tabela os sintomas desta doenca
        //depois vai chamar deepAccess() de RepositorioSintomaArray
      } else {
        throw new ObjectNotFoundException(ExceptionMessages.EXC_FALHA_PROCURA);
      }
      resultSet.close();
      stmt.close();

      // Query para recuperar os sintomas relacionados com o tipo
      // de doen�a encontrado a partir do c�digo
      sql = "select * from scbs_tipodoencasintoma where codigotipodoenca = '" + code + "'";

      stmt = (Statement) this.mp.getCommunicationChannel();
      resultSet = stmt.executeQuery(sql);

      sintomas = new ArrayList();
      while (resultSet.next()) {
        int codeSymptom = (new Integer(resultSet.getString("codigosintoma"))).intValue();

        // Query para encontrar os dados de um sintoma usando o
        // c�digo encontrado na tabela de relacionamentos.
        sql = "select * from scbs_sintoma where " + "codigo = '" + codeSymptom + "'";

        Statement stmt2 = (Statement) this.mp.getCommunicationChannel();
        ResultSet resultSet2 = stmt2.executeQuery(sql);
        Symptom sintoma;

        if (resultSet2.next()) {
          sintoma = new Symptom(resultSet2.getString("descricao"));
          sintoma.setId((new Long(resultSet2.getString("codigo"))).longValue());
        } else {
          // Caso esse trecho de c�digo seja executado,
          // a tabela de relacinoamentos n�o est� consistente
          // com a tabela de sintomas
          throw new ObjectNotFoundException(ExceptionMessages.EXC_FALHA_PROCURA);
        }
        resultSet2.close();
        stmt2.close();

        sintomas.add(sintoma);

      }
      resultSet.close();
      stmt.close();

      td = new DiseaseType(nome, descricao, manifestacao, duracao, sintomas);
      td.setId(code);

    } catch (PersistenceMechanismException e) {
      throw new RepositoryException(ExceptionMessages.EXC_FALHA_BD);
    } catch (SQLException e) {
      e.printStackTrace();
View Full Code Here

    this.vetor[indice] = tp;
    indice++;
  }

  public DiseaseType search(Long code) throws RepositoryException, ObjectNotFoundException {
    DiseaseType response = null;
    int i = getIndex(code);
    if (i == indice) {
      throw new ObjectNotFoundException("Disease not found");
    } else {
      response = vetor[i];
View Full Code Here

      if (repTP == null || !repTP.hasNext()) {
        out.println("</select></p></center></div>");
        out
        .println("<p><font color=\"red\"><b> There isn't diseases registered.</b></font></p>");
      } else {
        DiseaseType tp;
        do {
          tp = (DiseaseType) repTP.next();
         
          //#if relacional
          out.println("<option value=\"" + tp.getId() + "\"> "
              + tp.getName() + " </OPTION>");
          //#endif
         
          //#if norelacional
//@          out.println("<option value=\"" + tp.getCode() + "\"> " //thiago alterou aqui
//@              + tp.getName() + " </OPTION>");
View Full Code Here

      List<Long> ids = (List<Long>) q.execute();
      // O resultado da query � testado para saber
      // da exist�ncia de unidades de sa�de cadastradas.
      // Caso n�o existam uma exce��o � lan�ada.
      if (!ids.isEmpty()) {
        DiseaseType us = partialSearch(ids.get(0));
        listatd.add(us);
        try {
          ids.remove(0);
        } catch (UnsupportedOperationException uoe) {
          ids = new ArrayList<Long>(ids);
          ids.remove(0);
        }
      } else {
        throw new ObjectNotFoundException(ExceptionMessages.EXC_FALHA_PROCURA);
      }

      // O resultado da query � navegado, e cada
      // c�digo � informado � um m�todo (procura) que
      // monta uma unidade de s�ude a partir do c�digo.
      while (!ids.isEmpty()) {
        DiseaseType us = new DiseaseType();
        us = partialSearch(ids.get(0));
        listatd.add(us);
        ids.remove(0);
      }
      pm.close();
View Full Code Here

   *           do banco de dados
   * @throws RepositoryException
   */
  public DiseaseType partialSearch(Long codigo) throws ObjectNotFoundException, RepositoryException {
    PersistenceManager pm = (PersistenceManager) mp.getCommunicationChannel();
    DiseaseType td = null;

    try{
      String query = ("select from "+DiseaseType.class.getName()+" where id == "+codigo+"");
      List<DiseaseType> unidade = (List<DiseaseType>)pm.newQuery(query).execute();

View Full Code Here

   * @param code c�digo do tipo de doen�a a ser procurado
   * @return um objeto tipo doen�a montado a partir dos dados
   *       do banco de dados
   */
  public DiseaseType search(Long code) throws RepositoryException, ObjectNotFoundException {
    DiseaseType td = null;
    long asdf = code;
    int hehe = (int)asdf;
    String name, description, manifestation, duration;
    List<Symptom> symptoms;
   
    try{
      PersistenceManager pm = (PersistenceManager) mp.getCommunicationChannel();

      String queryUS = ("select from "+DiseaseType.class.getName()+" where teste == "+hehe+"");
      List<DiseaseType> listUs = (List<DiseaseType>)pm.newQuery(queryUS).execute();

      if (!listUs.isEmpty()){
        name = listUs.get(0).getName();
        description = listUs.get(0).getDescription();
        manifestation = listUs.get(0).getManifestation();
        duration = listUs.get(0).getDuration();
      }else{
        throw new ObjectNotFoundException(ExceptionMessages.EXC_FALHA_PROCURA);
      }


      pm.close();

      pm = (PersistenceManager) mp.getCommunicationChannel();
      String query = ("select from "+Symptom.class.getName()+" where teste == "+hehe+"");
      List<Symptom> listSym = (List<Symptom>)pm.newQuery(query).execute();
      List<Symptom> listSt = new ArrayList<Symptom>();

      if (!listSym.isEmpty()) {
        Symptom esp = symptomRep.search(listSym.get(0).getId());
        listSt.add(esp);
        try {
          listSym.remove(0);
        } catch (UnsupportedOperationException uoe) {
          listSym = new ArrayList<Symptom>(listSym);
          listSym.remove(0);
        }
      } else {
        //throw new ObjectNotFoundException(ExceptionMessages.EXC_FALHA_PROCURA);
      }

      while(!listSym.isEmpty()){
        Symptom ms = symptomRep.search(listSym.get(0).getId());
        listSt.add(ms);
        listSym.remove(0);
      }


      symptoms = listSt;
      td = new DiseaseType(name, description, manifestation, duration, symptoms);

    }catch(Exception e){
      e.printStackTrace();
    }
    return td;
View Full Code Here

TOP

Related Classes of healthwatcher.model.complaint.DiseaseType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.