@TransactionAttribute
  public String guardar() {
    String salida = "";
    System.out.println("Guardar__________");
    Date now = Calendar.getInstance().getTime();
    getInstance().setLastUpdate(now);
    getInstance().setTiempoConsulta(FechasUtil.sumarRestaMinutosFecha(now, 5));
    try {
      if (getInstance().isPersistent()) {
        // System.out.println("Guardar__________1" + getInstance().getId());
        getInstance().setCode("REALIZADA");
        getInstance().setResponsable(profileS.getProfileByIdentityKey(identity.getUser().getKey()));
        getInstance().getSignosVitales().setFechaActual(now);
        // System.out.println("Guardar__________ 2");
        save(getInstance());
        if (turno.isPersistent()) {
          turno.setEstado("Realizada");
          save(turno);
        }
        FacesMessage msg =
            new FacesMessage(
                "Se actualizo Consulta Odontológica: " + getInstance().getId() + " con éxito");
        FacesContext.getCurrentInstance().addMessage("", msg);
        System.out.println("Guardar__________3");
      } else {
        getInstance().setCode("REALIZADA");
        getInstance().setFichaOdontologica(fichaOdontolog);
        getInstance().setResponsable(profileS.getProfileByIdentityKey(identity.getUser().getKey()));
        getInstance().getSignosVitales().setFechaActual(now);
        create(getInstance().getSignosVitales());
        create(getInstance());
        save(getInstance());
        if (turno.isPersistent()) {
          turno.setEstado("Realizada");
          save(turno);
        }
        FacesMessage msg =
            new FacesMessage(
                "Se creo nueva Consulta Odontológica: " + getInstance().getId() + " con éxito");
        FacesContext.getCurrentInstance().addMessage("", msg);

        salida =
            "/pages/depSalud/odontologia/consultaOdontologica.xhtml?faces-redirect=true"
                + "&fichaMedicaId="
                + getFichaMedicaId()
                + "&consultaOdontId="
                + getInstance().getId()
                + "&backView="
                + getBackView();
      }
    } catch (Exception e) {
      e.printStackTrace();
      FacesMessage msg = new FacesMessage("Error al guardar: " + getInstance().getId());
      FacesContext.getCurrentInstance().addMessage("", msg);
    }
    return salida;
  }
 @TransactionAttribute
 public ConsultaOdontologica load() {
   if (isIdDefined()) {
     wire();
   }
   // log.info("sgssalud --> cargar instance " + getInstance());
   if (getInstance().isPersistent()) {
     if (getInstance().getResponsable() == null) {
       getInstance().setResponsable(profileS.getProfileByIdentityKey(identity.getUser().getKey()));
     }
   }
   return getInstance();
 }
示例#3
0
  /**
   * Authenticate jpa.
   *
   * @throws ClientException the client exception
   */
  protected void authenticateJPA() throws ClientException {
    User user = userDAO.getUserByLogin(credentials.getUsername());
    boolean hasNoError = true;

    hasNoError = authorizeUser(user);

    String password = null;
    if (hasNoError) {
      if (credentials != null && credentials.getCredential() instanceof PasswordCredential) {
        password = ((PasswordCredential) credentials.getCredential()).getValue();
      }
      if (password == null) {
        messages.error(new YoutestitMSG("error.login.password.require"));
        hasNoError = false;
      }
    }

    if (hasNoError) {
      final String cryptedPassword = Sha1Encryption.getInstance().encryptToSha1(password);

      if (user.getPassword().equals(cryptedPassword)) {
        loginEventSrc.fire(user);
        setUser(new SimpleUser(user.getLogin()));
        identity.getUser();
      } else {
        messages.error(new YoutestitMSG("error.login.password.wrong"));
        hasNoError = false;
      }
    }

    if (hasNoError) {
      setStatus(AuthenticationStatus.SUCCESS);
    } else {
      setStatus(AuthenticationStatus.FAILURE);
    }
  }
  @TransactionAttribute
  public String agregarPedido() {
    Date now = Calendar.getInstance().getTime();
    System.out.println("INGRESo a Guardar _________");
    String salida = null;
    boolean ning = false;
    for (ExamenLabClinico ex : listaExamenLab) {
      if (ex.isSelect()) {
        ning = true;
        break;
      }
    }
    try {
      if (!ning) {
        // save(getInstance());
        FacesMessage msg =
            new FacesMessage(FacesMessage.SEVERITY_WARN, "Debe seleccionar minimo un examen", null);
        FacesContext.getCurrentInstance().addMessage("", msg);
        // return null;
      } else {
        // this.listaPedidoExamenLabC = pickListExamenesLab.getTarget();
        pedido.setFichaOdontologica(fichaOdontolog);
        pedido.setPaciente(fichaOdontolog.getFichaMedica().getPaciente());
        pedido.setEstado("Nuevo");
        pedido.setResponsableEmision(profileS.getProfileByIdentityKey(identity.getUser().getKey()));
        pedido.setFechaPedido(now);
        create(pedido);
        save(pedido);
        update();
        // System.out.println("Guardo Con exito 0_________");
        ResultadoExamenLabClinico resultadoExa;
        List<Parametros> pl = null; //
        for (ExamenLabClinico ex : this.listaExamenLab) {
          if (ex.isSelect()) {
            resultadoExa = new ResultadoExamenLabClinico();
            resultadoExa.setExamenLab(ex);
            resultadoExa.setPedidoExamenLab(pedido);
            pl = examenLabService.getParametrosPorExamen(ex);
            resultadoExa.agregarValoresResultados(pl);
            save(resultadoExa);
            // update();
          }
        }

        FacesMessage msg =
            new FacesMessage(
                "Se agrego nuevo Pedido de Examenes: " + getInstance().getId() + " con éxito");
        FacesContext.getCurrentInstance().addMessage("", msg);
        pedido = new PedidoExamenLaboratorio();
        // hc = hcs.buscarPorFichaMedica(fms.getFichaMedicaPorId(fichaMedicaId));

        RequestContext.getCurrentInstance().update(":form:tabOpc:tablaPedidos :form:growl");
        RequestContext.getCurrentInstance().execute("pedidoDlg.hide();");
        salida =
            "/pages/depSalud/odontologia/consultaOdontologica.xhtml?faces-redirect=true"
                + "&fichaMedicaId="
                + getFichaMedicaId()
                + "&consultaOdontId="
                + getInstance().getId()
                + "&backView="
                + getBackView();
      }
    } catch (Exception e) {
      e.printStackTrace();
      FacesMessage msg = new FacesMessage("Error al guardar: " + getInstance().getId());
      FacesContext.getCurrentInstance().addMessage("", msg);
    }

    return salida;
  }