private int decodeNASMessage() {
    String[] items = Connection.getResponseItems(Connection.getValueAt(6));
    if (items == null) return 0;
    int records = items.length;
    if (records == 0) return 0;

    for (int x = 0; x < records; x++) {
      Go_mdt_hcpsRecord record = new Go_mdt_hcpsRecord();
      String[] valueItems = Connection.splitResponseItem(items[x]);

      record.Go_mdt_hcps_id =
          Connection.decodeFieldValue(Connection.getValueFor(valueItems, "GO_MDT_HCPS_ID"));
      record.Pkey = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "PKEY"));
      record.Rdat = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RDAT"));
      record.Rtim = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RTIM"));
      record.Rhcp = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RHCP"));
      record.Rusr = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RUSR"));
      record.Udat = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UDAT"));
      record.Utim = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UTIM"));
      record.Uhcp = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UHCP"));
      record.Uusr = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UUSR"));
      record.Cdat = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "CDAT"));
      record.Ctim = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "CTIM"));
      record.Modu = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "MODU"));
      record.Ccs_epid = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "CCS_EPID"));
      record.Actind = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "ACTIND"));
      record.Tstp = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "TSTP"));
      record.Session_id =
          Connection.decodeFieldValue(Connection.getValueFor(valueItems, "SESSION_ID"));
      record.Sessiond_id =
          Connection.decodeFieldValue(Connection.getValueFor(valueItems, "SESSIOND_ID"));

      DataCollection.add(record);
    }

    return records;
  }
  private int decodeNASMessageWithRepeatingGroups() {
    String[] items = Connection.getResponseItems(Connection.getValueAt(6));
    if (items == null) return 0;
    int records = items.length;
    if (records == 0) return 0;

    int recCount = 0;
    int rgCount = 0;

    for (int x = 0; x < records; x++) {
      Go_mdt_hcpsRecord record = new Go_mdt_hcpsRecord();
      String[] valueItems = Connection.splitResponseItem(items[x]);

      record.Go_mdt_hcps_id =
          Connection.decodeFieldValue(Connection.getValueFor(valueItems, "GO_MDT_HCPS_ID"));
      record.Pkey = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "PKEY"));
      record.Rdat = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RDAT"));
      record.Rtim = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RTIM"));
      record.Rhcp = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RHCP"));
      record.Rusr = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RUSR"));
      record.Udat = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UDAT"));
      record.Utim = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UTIM"));
      record.Uhcp = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UHCP"));
      record.Uusr = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UUSR"));
      record.Cdat = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "CDAT"));
      record.Ctim = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "CTIM"));
      record.Modu = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "MODU"));
      record.Ccs_epid = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "CCS_EPID"));
      record.Actind = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "ACTIND"));
      record.Tstp = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "TSTP"));
      record.Session_id =
          Connection.decodeFieldValue(Connection.getValueFor(valueItems, "SESSION_ID"));
      record.Sessiond_id =
          Connection.decodeFieldValue(Connection.getValueFor(valueItems, "SESSIOND_ID"));

      for (int i = 0; i < valueItems.length; i++)
        if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("seqno"))
          record.SeqnoCollection.add();

      rgCount = record.SeqnoCollection.count();
      if (rgCount > 0) {

        recCount = 0;
        for (int i = 0; i < valueItems.length; i++) {
          if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("seqno")) {
            Go_mdt_hcpsSeqnoRecord rgRecord = record.SeqnoCollection.get(recCount);
            rgRecord.Seqno = Connection.getAttributeValue(valueItems[i]);
            recCount++;
          }

          if (rgCount == recCount) break;
        }

        recCount = 0;
        for (int i = 0; i < valueItems.length; i++) {
          if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("attattended")) {
            Go_mdt_hcpsSeqnoRecord rgRecord = record.SeqnoCollection.get(recCount);
            rgRecord.Attattended = Connection.getAttributeValue(valueItems[i]);
            recCount++;
          }

          if (rgCount == recCount) break;
        }

        recCount = 0;
        for (int i = 0; i < valueItems.length; i++) {
          if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("attdeclined")) {
            Go_mdt_hcpsSeqnoRecord rgRecord = record.SeqnoCollection.get(recCount);
            rgRecord.Attdeclined = Connection.getAttributeValue(valueItems[i]);
            recCount++;
          }

          if (rgCount == recCount) break;
        }

        recCount = 0;
        for (int i = 0; i < valueItems.length; i++) {
          if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("attconfirmed")) {
            Go_mdt_hcpsSeqnoRecord rgRecord = record.SeqnoCollection.get(recCount);
            rgRecord.Attconfirmed = Connection.getAttributeValue(valueItems[i]);
            recCount++;
          }

          if (rgCount == recCount) break;
        }

        recCount = 0;
        for (int i = 0; i < valueItems.length; i++) {
          if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("methodinformed")) {
            Go_mdt_hcpsSeqnoRecord rgRecord = record.SeqnoCollection.get(recCount);
            rgRecord.Methodinformed = Connection.getAttributeValue(valueItems[i]);
            recCount++;
          }

          if (rgCount == recCount) break;
        }

        recCount = 0;
        for (int i = 0; i < valueItems.length; i++) {
          if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("dateinformed")) {
            Go_mdt_hcpsSeqnoRecord rgRecord = record.SeqnoCollection.get(recCount);
            rgRecord.Dateinformed = Connection.getAttributeValue(valueItems[i]);
            recCount++;
          }

          if (rgCount == recCount) break;
        }

        recCount = 0;
        for (int i = 0; i < valueItems.length; i++) {
          if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("hcp_txt")) {
            Go_mdt_hcpsSeqnoRecord rgRecord = record.SeqnoCollection.get(recCount);
            rgRecord.Hcp_txt = Connection.getAttributeValue(valueItems[i]);
            recCount++;
          }

          if (rgCount == recCount) break;
        }

        recCount = 0;
        for (int i = 0; i < valueItems.length; i++) {
          if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("hcp_id")) {
            Go_mdt_hcpsSeqnoRecord rgRecord = record.SeqnoCollection.get(recCount);
            rgRecord.Hcp_id = Connection.getAttributeValue(valueItems[i]);
            recCount++;
          }

          if (rgCount == recCount) break;
        }

        recCount = 0;
        for (int i = 0; i < valueItems.length; i++) {
          if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("ct_ext_flag")) {
            Go_mdt_hcpsSeqnoRecord rgRecord = record.SeqnoCollection.get(recCount);
            rgRecord.Ct_ext_flag = Connection.getAttributeValue(valueItems[i]);
            recCount++;
          }

          if (rgCount == recCount) break;
        }
      }

      DataCollection.add(record);
    }

    return records;
  }