@Override
 public void build(String input) {
   if (validate(input)) {
     if (input.length() < maxLength) {
       input = StringUtils.rightPad(input, maxLength, " ");
     }
     try {
       String values[] = MyStringUtil.splitByFixedLengths(input, new int[] {1, 400});
       this.resultado = values[0];
       if (this.resultado.equals("1")) {
         String empresaValues[] =
             StringUtils.splitPreserveAllTokens(values[1], Cuerpo.FIELD_SEPARATOR_CHAR);
         this.empresa = new Empresa();
         this.empresa.setRuc(empresaValues[0]);
         this.empresa.setNombre(empresaValues[1]);
         this.empresa.setTelefono(empresaValues[2]);
         this.empresa.setDireccion(empresaValues[3]);
         this.empresa.setUsuario(empresaValues[4]);
         this.empresa.setPassword(empresaValues[5]);
       }
     } catch (Exception ex) {
       Logger.getLogger(AutenticacionEmpresaRS.class.getName()).log(Level.SEVERE, null, ex);
     }
   }
 }
Beispiel #2
0
 private List<String> readLines(String content) {
   String[] lines = StringUtils.splitPreserveAllTokens(content, "\n");
   for (int i = 0; i < lines.length; i++) {
     String line = lines[i];
     lines[i] = StringUtils.stripEnd(line, "\r");
   }
   return Arrays.asList(lines);
 }
  @Override
  public VistaVeteranClinicalReminder extractData(String record) {
    // IEN^PRINT NAME^DUE DATE/TIME^LAST OCCURRENCE DATE/TIME
    // 500047^Hepatitis C risk Factor Screening^DUE NOW^^2^1^1^^^^0

    if (StringUtils.isBlank(record)) {
      return null;
    }

    VistaVeteranClinicalReminder vistaVeteranClinicalReminder = new VistaVeteranClinicalReminder();

    String[] fields = StringUtils.splitPreserveAllTokens(record, '^');

    // 0. IEN
    vistaVeteranClinicalReminder.setClinicalReminderIen(fields[0]);

    // 1. Name
    vistaVeteranClinicalReminder.setName(fields[1]);

    // 2. Due Date
    if (StringUtils.isNotBlank(fields[2])) {
      if (!"DUE NOW".equalsIgnoreCase(fields[2])) {
        Date dueDate = VistaUtils.convertVistaDate(fields[2]);

        if (dueDate != null) {
          vistaVeteranClinicalReminder.setDueDateString(
              clinicalReminderDueDateFormat.format(dueDate));
        }
      } else {
        vistaVeteranClinicalReminder.setDueDateString(fields[2]);
      }
    }
    // So, if piece 6 (5th index) is set to 1... then the reminder is “Due”. We can see this
    // reflected in the document Liz sent....
    // 918^Evaluation of + PTSD Screen^DUE NOW^^2^1^1^^^^1     <—Says “Due Now”, and piece 6 is set
    // to “1” for “Due”
    // <—snip—>
    // 265^Screen for PTSD^3151124.083813^3141124.083813^2^1^1^^^^1  <—Says due “3141124.083813”,
    // and piece 6 is set to “1” for “Due”
    int dueNowStatus = 0; // not due
    try {
      dueNowStatus = Integer.parseInt(fields[5]);
    } catch (NumberFormatException nfe) {
      logger.error(Throwables.getRootCause(nfe).getMessage());
    }
    vistaVeteranClinicalReminder.setDueNow(dueNowStatus == 1);

    return vistaVeteranClinicalReminder;
  }