Пример #1
1
  /** 選択されている行をコピーする。 */
  public void copyRow() {

    StringBuilder sb = new StringBuilder();
    int numRows = view.getTable().getSelectedRowCount();
    int[] rowsSelected = view.getTable().getSelectedRows();
    int numColumns = view.getTable().getColumnCount();

    for (int i = 0; i < numRows; i++) {
      if (tableModel.getObject(rowsSelected[i]) != null) {
        StringBuilder s = new StringBuilder();
        for (int col = 0; col < numColumns; col++) {
          Object o = view.getTable().getValueAt(rowsSelected[i], col);
          if (o != null) {
            s.append(o.toString());
          }
          s.append(",");
        }
        if (s.length() > 0) {
          s.setLength(s.length() - 1);
        }
        sb.append(s.toString()).append("\n");
      }
    }
    if (sb.length() > 0) {
      StringSelection stsel = new StringSelection(sb.toString());
      Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stsel, stsel);
    }
  }
Пример #2
0
  /**
   * 検索を実行する。
   *
   * @param text キーワード
   */
  private void find(String text) {

    Log.outputFuncLog(Log.LOG_LEVEL_0, Log.FUNCTIONLOG_KIND_INFORMATION, "患者検索", text);

    // 全角スペースをkill
    text = text.replaceAll(" ", " ");

    PatientSearchSpec spec = new PatientSearchSpec();

    if (isDate(text)) {
      spec.setCode(PatientSearchSpec.DATE_SEARCH);
      spec.setDigit(text);

    } else if (StringTool.startsWithKatakana(text)) {
      spec.setCode(PatientSearchSpec.KANA_SEARCH);
      spec.setName(text);

    } else if (StringTool.startsWithHiragana(text)) {
      text = StringTool.hiraganaToKatakana(text);
      spec.setCode(PatientSearchSpec.KANA_SEARCH);
      spec.setName(text);

    } else if (isNameAddress(text)) {
      spec.setCode(PatientSearchSpec.NAME_SEARCH);
      spec.setName(text);

    } else {

      if (Project.getBoolean("zero.paddings.id.search", false)) {
        int len = text.length();
        int paddings = Project.getInt("patient.id.length", 0) - len;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < paddings; i++) {
          sb.append("0");
        }
        sb.append(text);
        text = sb.toString();
      }

      spec.setCode(PatientSearchSpec.DIGIT_SEARCH);
      spec.setDigit(text);
    }

    final PatientSearchSpec searchSpec = spec;

    SimpleWorker worker =
        new SimpleWorker<Collection, Void>() {

          @Override
          protected Collection doInBackground() throws Exception {
            PatientDelegater pdl = new PatientDelegater();
            Collection result = pdl.getPatients(searchSpec);
            return result;
          }

          @Override
          protected void succeeded(Collection result) {

            List<PatientModel> list = (List<PatientModel>) result;

            if (list != null && list.size() > 0) {

              // minagawa^ 仮保存カルテ取得対応
              /*
              boolean sorted = true;
              for (int i=0; i < COLUMN_NAMES.length; i++) {
                  if (sorter.getSortingStatus(i)==0) {
                      sorted = false;
                      break;
                  }
              }

              if (!sorted) {

                  switch (sortItem) {
                      case 0:
                          Comparator c = new Comparator<PatientModel>() {

                              @Override
                              public int compare(PatientModel o1, PatientModel o2) {
                                  return o1.getPatientId().compareTo(o2.getPatientId());
                              }
                          };
                          Collections.sort(list, c);
                          break;
                      case 1:
                        Comparator c2 = new Comparator<PatientModel>() {

                          @Override
                           public int compare(PatientModel p1, PatientModel p2) {
                              String kana1 = p1.getKanaName();
                              String kana2 = p2.getKanaName();
                              if (kana1 != null && kana2 != null) {
                                  return p1.getKanaName().compareTo(p2.getKanaName());
                              } else if (kana1 != null && kana2 == null) {
                                  return -1;
                              } else if (kana1 == null && kana2 != null) {
                                  return 1;
                              } else {
                                  return 0;
                              }
                          }
                        };
                      Collections.sort(list, c2);
                      break;
                  }
              }
              */
              sortList(list);
              // minagawa$

              tableModel.setDataProvider(list);
              Log.outputFuncLog(
                  Log.LOG_LEVEL_0,
                  Log.FUNCTIONLOG_KIND_INFORMATION,
                  "患者数:",
                  String.valueOf(list.size()));
            } else {
              tableModel.clear();
              Log.outputFuncLog(Log.LOG_LEVEL_0, Log.FUNCTIONLOG_KIND_INFORMATION, "患者数:", "0");
            }
            updateStatusLabel();
          }

          @Override
          protected void failed(Throwable cause) {}

          @Override
          protected void startProgress() {
            doStartProgress();
          }

          @Override
          protected void stopProgress() {
            doStopProgress();
          }
        };

    worker.execute();
  }