// Metodo para guardar la informacion //
  public void guardarDatos() throws Exception {
    try {
      // log.info("ejecutando metodo guardarDatos()");
      if (validarForm()) {
        FormularioUtil.setUpperCase(groupboxEditar);
        // Cargamos los componentes //

        Maestro_manual maestro_manual = new Maestro_manual();
        maestro_manual.setId_manual(
            (lgxId_manual.getValue() != null ? lgxId_manual.getValue() : 0L));
        maestro_manual.setCodigo_empresa(codigo_empresa);
        maestro_manual.setCodigo_sucursal(codigo_sucursal);
        maestro_manual.setManual(tbxManual.getValue());
        maestro_manual.setTipo_manual(lbxTipo_manual.getSelectedItem().getValue().toString());
        maestro_manual.setTipo_moneda(lbxTipo_moneda.getSelectedItem().getValue().toString());
        maestro_manual.setCreacion_date(new Timestamp(new GregorianCalendar().getTimeInMillis()));
        maestro_manual.setCreacion_user(usuarios.getCodigo().toString());
        Map<String, Object> mapa_datos = new HashMap<String, Object>();
        mapa_datos.put("maestro_manual", maestro_manual);
        mapa_datos.put("accion", tbxAccion.getValue());
        mapa_datos.put("mapa_datos_procedimientos", mapa_datos_procedimientos);
        maestro_manualService.guardarDatos(mapa_datos);
        tbxAccion.setValue("modificar");
        mostrarDatos(maestro_manual);
        MensajesUtil.mensajeInformacion(
            "Informacion ..", "Los datos se guardaron satisfactoriamente");
      }

    } catch (Exception e) {
      MensajesUtil.mensajeError(e, "", this);
    }
  }
  // Metodo para colocar los datos del objeto que se consulta en la vista //
  public void mostrarDatos(Object obj) throws Exception {
    Maestro_manual maestro_manual = (Maestro_manual) obj;
    try {
      procedimientos_seleccionados.clear();
      mapa_datos_procedimientos.clear();
      lgxId_manual.setValue(maestro_manual.getId_manual());
      tbxManual.setValue(maestro_manual.getManual());
      Utilidades.seleccionarListitem(lbxTipo_manual, maestro_manual.getTipo_manual());
      Utilidades.seleccionarListitem(lbxTipo_moneda, maestro_manual.getTipo_moneda());

      listboxProcedimientos.getItems().clear();

      Map<String, Object> parametros = new HashMap<String, Object>();
      parametros.put("id_manual", maestro_manual.getId_manual());

      List<Manuales_procedimientos> listado_procedimientos =
          getServiceLocator().getServicio(Manuales_procedimientosService.class).listar(parametros);

      for (Manuales_procedimientos manuales_procedimientos : listado_procedimientos) {
        Long id_procedimiento = manuales_procedimientos.getId_procedimiento();
        Procedimientos procedimientos = new Procedimientos();
        procedimientos.setId_procedimiento(id_procedimiento);
        procedimientos = getServiceLocator().getProcedimientosService().consultar(procedimientos);
        Map<String, Object> pcd =
            OpenProcedimientosAction.getProcedimientoMap(
                codigo_empresa, codigo_sucursal, procedimientos);
        mapa_datos_procedimientos.put(id_procedimiento, pcd);
        pcd.put("codigo_manual", manuales_procedimientos.getCodigo_manual());
        pcd.put("valor", manuales_procedimientos.getValor());
        pcd.put("grupo_uvr", manuales_procedimientos.getGrupo_uvr());
        pcd.put(
            "nro_cuenta",
            manuales_procedimientos.getNro_cuenta_contable() != null
                ? manuales_procedimientos.getNro_cuenta_contable()
                : "");
        adicionarProcedimiento(pcd);
        procedimientos_seleccionados.add(id_procedimiento + "");
      }

      // Mostramos la vista //
      tbxAccion.setText("modificar");
      accionForm(true, tbxAccion.getText());
    } catch (Exception e) {
      MensajesUtil.mensajeError(e, "", this);
    }
  }
  // Metodo para colocar los datos del objeto que se consulta en la vista //
  public void mostrarDatos(Object obj) throws Exception {
    Anexo3_entidad anexo3_entidad = (Anexo3_entidad) obj;
    try {
      tbxCodigo.setValue(anexo3_entidad.getCodigo());
      tbxNumero_solicitud.setValue(anexo3_entidad.getNumero_solicitud());
      dtbxFecha.setValue(anexo3_entidad.getFecha());
      // tbxCodigo_administradora.setValue(anexo3_entidad
      // .getCodigo_administradora());
      tbxNomPaciente.setValue(anexo3_entidad.getCodigo_paciente());
      Utilidades.seleccionarRadio(rdbCobertura, anexo3_entidad.getCobertura());
      Utilidades.seleccionarRadio(rdbOrigen_general, anexo3_entidad.getOrigen_general());
      Utilidades.seleccionarRadio(rdbOrigen_profesional, anexo3_entidad.getOrigen_profesional());
      Utilidades.seleccionarRadio(rdbOrigen_trabajo, anexo3_entidad.getOrigen_trabajo());
      Utilidades.seleccionarRadio(rdbOrigen_transito, anexo3_entidad.getOrigen_transito());
      Utilidades.seleccionarRadio(rdbOrigen_evento, anexo3_entidad.getOrigen_evento());
      Utilidades.seleccionarRadio(rdbTipo_servicio, anexo3_entidad.getTipo_servicio());
      Utilidades.seleccionarRadio(rdbPrioridad, anexo3_entidad.getPrioridad());
      Utilidades.seleccionarRadio(rdbUbicacion, anexo3_entidad.getUbicacion());
      tbxServicio.setValue(anexo3_entidad.getServicio());
      tbxCama.setValue(anexo3_entidad.getCama());
      tbxGuia_atencion.setValue(anexo3_entidad.getGuia_atencion());
      tbxJustificacion.setValue(anexo3_entidad.getJustificacion());
      tbxCie_p.setValue(anexo3_entidad.getCie_p());
      tbxCie_1.setValue(anexo3_entidad.getCie_1());
      tbxCie_2.setValue(anexo3_entidad.getCie_2());
      tbxCargo_reporta.setValue(anexo3_entidad.getCargo_reporta());
      tbxTel_reporta.setValue(anexo3_entidad.getTel_reporta());
      // dtbxDelete_date
      // .setValue(anexo3_entidad.getDelete_date() != null ?
      // anexo3_entidad
      // .getDelete_date() : new Date());
      // tbxDelete_user.setValue(anexo3_entidad.getDelete_user());
      tbxAutorizado.setValue(anexo3_entidad.getAutorizado());
      tbxCodigo_ips.setValue(anexo3_entidad.getCodigo_ips());
      tbxCons_ips.setValue(anexo3_entidad.getCons_ips());
      tbxLeido.setValue(anexo3_entidad.getLeido());
      tbxLeido_rechazado.setValue(anexo3_entidad.getLeido_rechazado());
      tbxNro_historia.setValue(anexo3_entidad.getNro_historia());
      tbxNeed_autorizacion.setValue(anexo3_entidad.getNeed_autorizacion());
      tbxCodigo_receta.setValue(anexo3_entidad.getCodigo_receta());

      tbxNombre_reporta.setValue(anexo3_entidad.getNombre_reporta());
      // tbxCel_reporta.setValue(anexo3_entidad.getCel_reporta());
      // tbxEntidad.setValue(anexo3_entidad.getEntidad());
      // tbxTipo_anexo.setValue(anexo3_entidad.getTipo_anexo());
      // tbxEstado.setValue(anexo3_entidad.getEstado());
      tbxNro_identificacion_reporta.setValue(anexo3_entidad.getNro_identificacion_reporta());

      tbxDirPres.setValue(anexo3_entidad.getDireccion_reporta());

      Map<String, Object> parametros = new HashMap<String, Object>();
      parametros.put("codigo_empresa", codigo_empresa);
      parametros.put("codigo_sucursal", codigo_sucursal);
      parametros.put("codigo_orden", anexo3_entidad.getCodigo());

      List<Detalle_anexo3> listado_detalles =
          getServiceLocator().getServicio(Detalle_anexo3Service.class).listar(parametros);

      for (Detalle_anexo3 detalle_anexo3 : listado_detalles) {
        Detalle_orden detalle_orden = new Detalle_orden();
        detalle_orden.setCodigo_empresa(codigo_empresa);
        detalle_orden.setCodigo_sucursal(codigo_sucursal);
        detalle_orden.setCodigo_cups(detalle_anexo3.getCodigo_cups());
        //				detalle_orden.setCodigo_orden(detalle_anexo3.getCodigo_orden());
        detalle_orden.setCodigo_procedimiento(detalle_anexo3.getCodigo_procedimiento());
        detalle_orden.setConsecutivo(detalle_anexo3.getConsecutivo());
        detalle_orden.setDescuento(detalle_anexo3.getDescuento());
        detalle_orden.setIncremento(detalle_anexo3.getIncremento());
        detalle_orden.setNombre_procedimiento(detalle_anexo3.getNombre_pcd());
        detalle_orden.setRealizado("");
        detalle_orden.setTipo_procedimiento(detalle_anexo3.getTipo_procedimiento());
        detalle_orden.setUnidades(detalle_anexo3.getUnidades());
        detalle_orden.setUnidades_realizadas(0);
        detalle_orden.setValor_procedimiento(detalle_anexo3.getValor_procedimiento());
        detalle_orden.setValor_real(detalle_anexo3.getValor_real());
        orden_servicioAction.adicionarOrden(detalle_orden, detalle_anexo3.getNombre_pcd());
      }
      // Mostramos la vista //
      tbxAccion.setText("modificar");
      accionForm(true, tbxAccion.getText());
    } catch (Exception e) {
      MensajesUtil.mensajeError(e, "", this);
    }
  }
  // Metodo para guardar la informacion //
  public void guardarDatos() throws Exception {
    try {
      FormularioUtil.setUpperCase(groupboxEditar);
      if (validarForm()) {
        // Cargamos los componentes //
        Anexo3_entidad anexo3_entidad = new Anexo3_entidad();
        anexo3_entidad.setCodigo_empresa(empresa.getCodigo_empresa());
        anexo3_entidad.setCodigo_sucursal(sucursal.getCodigo_sucursal());
        anexo3_entidad.setNumero_solicitud(tbxNumero_solicitud.getValue());
        anexo3_entidad.setFecha(new Timestamp(dtbxFecha.getValue().getTime()));

        anexo3_entidad.setCodigo(tbxCodigo.getValue());

        anexo3_entidad.setCodigo_paciente(tbxCodigo_paciente_a3.getValue());
        anexo3_entidad.setCobertura(rdbCobertura.getSelectedItem().getValue().toString());
        anexo3_entidad.setOrigen_general(rdbOrigen_general.getSelectedItem().getValue().toString());
        anexo3_entidad.setOrigen_profesional(
            rdbOrigen_profesional.getSelectedItem().getValue().toString());
        anexo3_entidad.setOrigen_trabajo(rdbOrigen_trabajo.getSelectedItem().getValue().toString());
        anexo3_entidad.setOrigen_transito(
            rdbOrigen_transito.getSelectedItem().getValue().toString());
        anexo3_entidad.setOrigen_evento(rdbOrigen_evento.getSelectedItem().getValue().toString());
        anexo3_entidad.setTipo_servicio(rdbTipo_servicio.getSelectedItem().getValue().toString());
        anexo3_entidad.setPrioridad(rdbPrioridad.getSelectedItem().getValue().toString());
        anexo3_entidad.setUbicacion(rdbUbicacion.getSelectedItem().getValue().toString());
        anexo3_entidad.setServicio(tbxServicio.getValue());
        anexo3_entidad.setCama(tbxCama.getValue());
        anexo3_entidad.setGuia_atencion(tbxGuia_atencion.getValue());
        anexo3_entidad.setJustificacion(tbxJustificacion.getValue());
        anexo3_entidad.setCie_p(tbxCie_p.getValue());
        anexo3_entidad.setCie_1(tbxCie_1.getValue());
        anexo3_entidad.setCie_2(tbxCie_2.getValue());
        anexo3_entidad.setCargo_reporta(tbxCargo_reporta.getValue());
        anexo3_entidad.setTel_reporta(tbxTel_reporta.getValue());
        anexo3_entidad.setCreacion_date(new Timestamp(new GregorianCalendar().getTimeInMillis()));
        anexo3_entidad.setUltimo_update(new Timestamp(new GregorianCalendar().getTimeInMillis()));
        anexo3_entidad.setDelete_date(null);
        anexo3_entidad.setCreacion_user(usuarios.getCodigo().toString());
        anexo3_entidad.setUltimo_user(usuarios.getCodigo().toString());
        // anexo3_entidad.setDelete_user(tbxDelete_user.getValue());
        anexo3_entidad.setAutorizado(tbxAutorizado.getValue());
        anexo3_entidad.setCodigo_ips(tbxCodigo_ips.getValue());
        anexo3_entidad.setCons_ips(tbxCons_ips.getValue());
        anexo3_entidad.setLeido(tbxLeido.getValue());
        anexo3_entidad.setLeido_rechazado(tbxLeido_rechazado.getValue());
        anexo3_entidad.setNro_historia(tbxNro_historia.getValue());
        anexo3_entidad.setNeed_autorizacion(tbxNeed_autorizacion.getValue());
        anexo3_entidad.setCodigo_receta(tbxCodigo_receta.getValue());

        anexo3_entidad.setNombre_reporta(tbxNombre_reporta.getValue());
        anexo3_entidad.setNro_identificacion_reporta(tbxNro_identificacion_reporta.getValue());
        anexo3_entidad.setNro_ingreso(admision_seleccionada.getNro_ingreso());
        anexo3_entidad.setDireccion_reporta(tbxDirPres.getValue());

        // anexo3_entidad.setCel_reporta(tbxCel_reporta.getValue());
        // anexo3_entidad.setEntidad(tbxEntidad.getValue());
        // anexo3_entidad.setTipo_anexo(tbxTipo_anexo.getValue());
        // anexo3_entidad.setEstado(tbxEstado.getValue());

        Map<String, Object> mapa_datos = new HashMap<String, Object>();
        mapa_datos.put("accion", tbxAccion.getValue());
        mapa_datos.put("anexo3_entidad", anexo3_entidad);
        mapa_datos.put("orden_procedimientos", orden_servicioAction.obtenerDatos());

        anexo3_entidadService.guardarDatos(mapa_datos);

        tbxCodigo.setValue(anexo3_entidad.getCodigo());
        tbxAccion.setValue("modificar");

        MensajesUtil.mensajeInformacion(
            "Informacion ..", "Los datos se guardaron satisfactoriamente");
      }

    } catch (Exception e) {
      MensajesUtil.mensajeError(e, "", this);
    }
  }