/** Carga en la lista las impresoras para la impresion de stickers */
 public void cargarImpresoraTurnos() {
   listaImpresorasturnos = new ArrayList<>();
   for (AdmDatosGlobales datosGlobales : listaDatosGlobales) {
     if (datosGlobales.getTipo().equals(TIPO_IMPRESORAS)) {
       listaImpresorasturnos.add(datosGlobales);
     }
   }
 }
  /*
   * Metodo que imprime directamente en una impresra byte
   */
  public void printExtra(CexAgenda turno) throws IOException {
    // FileInputStream inputStream = null;
    InputStream tex = null;
    SimpleDateFormat sf = new SimpleDateFormat("dd/MM/yyyy");
    String fecha = sf.format(turno.getCagFecha());
    SimpleDateFormat sfHora = new SimpleDateFormat("HH:mm");
    String hora = "";
    String te2;
    if (turno.getCagHora() != null) {
      hora = sfHora.format(turno.getCagHora());
    }
    String impresora = "SIN IMPRESORA";
    PrintService impresora11 = null;
    try {
      // inputStream = new FileInputStream("e:/archivo.txt");

      String cadena =
          "************************************* \n\n"
                      + "RESPONSABLE: "
                      + turno.getCagNombreUsuario()
                      + " \n"
                      + "FECHA: "
                      + fecha
                      + " \n"
                      + turno.getCagNombreInstitucion()
                      + "\n"
                      + turno
                          .getCexHorariosDia()
                          .getCexHorario()
                          .getCexEspecialidadMedico()
                          .getCexEspecialidad()
                          .getCesNombre()
                      + "\n"
                      + "NÚMERO CARPETA: "
                      + turno.getHosReferencia()
                  != null
              ? turno.getHosReferencia().getCexHistoriaInstitucion().getCicNumeroCarpeta()
              : turno.getCexHistoriaInstitucion().getCicNumeroCarpeta()
                          + "\n"
                          + "CÉDULA: "
                          + turno.getHosReferencia()
                      != null
                  ? turno
                      .getHosReferencia()
                      .getCexHistoriaInstitucion()
                      .getCexHistoriaClinica()
                      .getChcCedula()
                  : turno.getCexHistoriaInstitucion().getCexHistoriaClinica().getChcCedula()
                              + "\n"
                              + "TURNO: "
                              + turno.getCagSecuencia()
                              + "\t HORA: "
                              + hora
                              + " \n"
                              + "MEDICO: "
                              + turno
                                  .getCexHorariosDia()
                                  .getCexHorario()
                                  .getCexEspecialidadMedico()
                                  .getAdmMedico()
                                  .getAmeNombreFull()
                              + "\n"
                              + "PACIENTE: "
                              + turno.getHosReferencia()
                          != null
                      ? turno
                          .getHosReferencia()
                          .getCexHistoriaInstitucion()
                          .getCexHistoriaClinica()
                          .getChcNombreFull()
                      : turno.getCexHistoriaInstitucion().getCexHistoriaClinica().getChcNombreFull()
                          + "\n"
                          + "*******   TURNO        EXTRA    ********\n"
                          + "\n"
                          + "\n"
                          + "SE RECOMIENDA ESTAR 30 MIN ANTES\n"
                          + " DE LA HORA ESPECIFICADA\n"
                          + "\n";
      te2 = converteCaracter(cadena);
      tex = new ByteArrayInputStream(te2.getBytes("UTF-8"));

    } catch (UnsupportedEncodingException e) {
      log.error("printExtra() {} ", e.getMessage());
    }
    if (tex == null) {
      return;
    }

    DocFlavor docFormat = DocFlavor.INPUT_STREAM.AUTOSENSE;
    Doc document = new SimpleDoc(tex, docFormat, null);

    PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();

    for (AdmDatosGlobales datoGlobal : listaImpresorasturnos) {
      if (user.getIp().equals(datoGlobal.getClave())) {
        impresora = datoGlobal.getValor();
        break;
      }
    }
    // PrintService impresora11 = PrintServiceLookup.lookupDefaultPrintService();
    PrintService[] printService = PrintServiceLookup.lookupPrintServices(null, null);
    for (PrintService printService1 : printService) {
      if (printService1.getName().equals(impresora)) {
        impresora11 = printService1;
      }
    }

    if (impresora11 != null) {
      DocPrintJob printJob = impresora11.createPrintJob();
      try {
        printJob.print(document, attributeSet);
      } catch (PrintException e) {
        log.error("printExtra() {} ", e.getMessage());
      }
    } else {
      log.error("No existen impresoras instaladas");
    }

    tex.close();
  }