private void initComponents() {

    final SimpleDateFormat dateFrmt = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
    panel = new JPanel();
    panel.setLayout(new BorderLayout());
    JPanel north = new JPanel();
    north.setLayout(new BoxLayout(north, BoxLayout.X_AXIS));
    JLabel dateLbl = new JLabel("検査日:");
    north.add(dateLbl);
    dateFld = new JTextField(10);
    dateFld.setMaximumSize(dateFld.getPreferredSize());
    dateFld.setEditable(false);
    dateFld.setText(dateFrmt.format(new Date()));
    north.add(dateFld);
    north.add(Box.createHorizontalGlue());
    editCheck = new JCheckBox("項目編集");
    north.add(editCheck);
    panel.add(north, BorderLayout.NORTH);

    JPanel south = new JPanel();
    south.setLayout(new FlowLayout());
    deleteBtn = new JButton("削除", deleteIcon);
    deleteBtn.setEnabled(false);
    south.add(deleteBtn);
    closeBtn = new JButton("閉じる", closeIcon);
    south.add(closeBtn);
    saveBtn = new JButton("保存", saveIcon);
    south.add(saveBtn);
    panel.add(south, BorderLayout.SOUTH);

    setTable = new JTable();
    JScrollPane scroll = new JScrollPane(setTable);
    centerPanel = new JPanel();
    centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.X_AXIS));
    centerPanel.add(scroll);
    panel.add(centerPanel, BorderLayout.CENTER);

    templateTable = new JTable();
    templateTable.setToolTipText("DnDで左の施設内検査項目テーブルに追加してください。");
    rtScroll = new JScrollPane(templateTable);
    Dimension d = new Dimension(200, 200);
    rtScroll.setPreferredSize(d);
    d = new Dimension(200, Integer.MAX_VALUE);
    rtScroll.setMaximumSize(d);

    dialog = new JDialog();
    String title = ClientContext.getFrameTitle("院内検査項目追加");
    dialog.setTitle(title);
    dialog.setModal(true);
    dialog.setContentPane(panel);
    ClientContext.setDolphinIcon(dialog);

    dialog.pack();
    dialog.setLocationRelativeTo(chart.getFrame());
  }
Ejemplo n.º 2
0
    private void maybeShowPopup(MouseEvent e) {

      if (e.isPopupTrigger()) {
        popup = new JPopupMenu();
        CalendarCardPanel cc = new CalendarCardPanel(ClientContext.getEventColorTable());
        cc.addPropertyChangeListener(CalendarCardPanel.PICKED_DATE, this);
        cc.setCalendarRange(new int[] {-12, 0});
        popup.insert(cc, 0);
        popup.show(e.getComponent(), e.getX(), e.getY());
      }
    }
 protected void failed(Throwable e) {
   e.printStackTrace(System.err);
   StringBuilder why = new StringBuilder();
   why.append(ERROR_ACCESS);
   why.append("\n");
   Throwable cause = e.getCause();
   if (cause != null) {
     why.append(cause.getMessage());
   } else {
     why.append(e.getMessage());
   }
   Window parent = SwingUtilities.getWindowAncestor(chart.getFrame());
   JOptionPane.showMessageDialog(
       parent, why.toString(), ClientContext.getFrameTitle(TITLE), JOptionPane.WARNING_MESSAGE);
 }
Ejemplo n.º 4
0
  /** GUI コンポーネントを初期化する。 */
  private void initComponents() {

    view = new NLabTestImportView();
    setUI(view);

    String[] columnNames =
        new String[] {"ラボ", "患者ID", "カナ", "カルテ・カナ", "性別", "カルテ・性別", "検体採取日", "項目数", "登録"};
    String[] propNames =
        new String[] {
          "laboCode",
          "patientId",
          "patientName",
          "karteKanaName",
          "patientSex",
          "karteSex",
          "sampleDate",
          "numOfTestItems",
          "result"
        };
    int[] columnWidth = new int[] {50, 120, 120, 120, 50, 70, 120, 50, 80};

    tableModel = new ListTableModel<NLaboImportSummary>(columnNames, 30, propNames, null);
    view.getTable().setModel(tableModel);
    view.getTable().setRowHeight(ClientContext.getHigherRowHeight());
    view.getTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    view.getTable().setTransferHandler(new NLaboTestFileTransferHandler(this));

    // カラム幅を変更する
    for (int i = 0; i < columnWidth.length; i++) {
      view.getTable().getColumnModel().getColumn(i).setPreferredWidth(columnWidth[i]);
    }

    // レンダラを設定する
    view.getTable().setDefaultRenderer(Object.class, new NLaboTestImporter.LabTestRenderer());

    // カウント値0を設定する
    updateCount();
  }
Ejemplo n.º 5
0
  public void openKarte() {

    boolean showReceiptMessage = Project.getBoolean("showReceiptMessage", true);
    if (showReceiptMessage) {
      JLabel msg1 = new JLabel("受付リストからオープンしないと診療データをレセコンに");
      JLabel msg2 = new JLabel("送信することができません。続けますか?");
      final JCheckBox cb = new JCheckBox("今後このメッセージを表示しない");
      cb.setFont(new Font("Dialog", Font.PLAIN, 10));
      cb.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Project.setBoolean("showReceiptMessage", !cb.isSelected());
            }
          });
      JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 3));
      p1.add(msg1);
      JPanel p2 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 3));
      p2.add(msg2);
      JPanel p3 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 3));
      p3.add(cb);
      JPanel box = new JPanel();
      box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
      box.add(p1);
      box.add(p2);
      box.add(p3);
      box.setBorder(BorderFactory.createEmptyBorder(0, 0, 11, 11));

      int option =
          JOptionPane.showConfirmDialog(
              SwingUtilities.getWindowAncestor(getUI()),
              new Object[] {box},
              ClientContext.getFrameTitle(getName()),
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              ClientContext.getImageIcon("about_32.gif"));

      if (option != JOptionPane.YES_OPTION) {
        return;
      }
    }

    PatientModel patient = selectedLabo.getPatient();
    PatientVisitModel pvt = new PatientVisitModel();
    pvt.setNumber(number++);
    pvt.setPatientModel(patient);

    // 受け付けを通していないので診療科はユーザ登録してあるものを使用する
    // 診療科名、診療科コード、医師名、医師コード、JMARI
    // 2.0
    pvt.setDeptName(Project.getUserModel().getDepartmentModel().getDepartmentDesc());
    pvt.setDeptCode(Project.getUserModel().getDepartmentModel().getDepartment());
    pvt.setDoctorName(Project.getUserModel().getCommonName());
    if (Project.getUserModel().getOrcaId() != null) {
      pvt.setDoctorId(Project.getUserModel().getOrcaId());
    } else {
      pvt.setDoctorId(Project.getUserModel().getUserId());
    }
    pvt.setJmariNumber(Project.getString(Project.JMARI_CODE));

    // カルテコンテナを生成する
    getContext().openKarte(pvt);
  }
Ejemplo n.º 6
0
/**
 * LabTestImporter
 *
 * @author Kazushi Minagawa, Digital Globe, Inc.
 */
public class NLaboTestImporter extends AbstractMainComponent {

  private static final String NAME = "ラボレシーバ";
  private static final String SUCCESS = "成功";
  private static final String ERROR = "エラー";
  private static final Color ODD_COLOR = ClientContext.getColor("color.odd");
  private static final Color EVEN_COLOR = ClientContext.getColor("color.even");
  private static final Color UNCONSTRAINED_COLOR = new Color(255, 102, 102);

  // 選択されている患者情報
  private NLaboImportSummary selectedLabo;
  private int number = 100000;

  // View
  private ListTableModel<NLaboImportSummary> tableModel;
  private NLabTestImportView view;

  /** Creates new NLaboTestImporter */
  public NLaboTestImporter() {
    setName(NAME);
  }

  @Override
  public void start() {
    initComponents();
    connect();
    enter();
  }

  @Override
  public void enter() {
    controlMenu();
  }

  @Override
  public void stop() {}

  public JProgressBar getProgressBar() {
    return getContext().getProgressBar();
  }

  public ListTableModel<NLaboImportSummary> getTableModel() {
    return (ListTableModel<NLaboImportSummary>) view.getTable().getModel();
  }

  public NLaboImportSummary getSelectedLabo() {
    return selectedLabo;
  }

  public void setSelectedLabo(NLaboImportSummary selectedLabo) {
    this.selectedLabo = selectedLabo;
    controlMenu();
  }

  public void openKarte() {

    boolean showReceiptMessage = Project.getBoolean("showReceiptMessage", true);
    if (showReceiptMessage) {
      JLabel msg1 = new JLabel("受付リストからオープンしないと診療データをレセコンに");
      JLabel msg2 = new JLabel("送信することができません。続けますか?");
      final JCheckBox cb = new JCheckBox("今後このメッセージを表示しない");
      cb.setFont(new Font("Dialog", Font.PLAIN, 10));
      cb.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Project.setBoolean("showReceiptMessage", !cb.isSelected());
            }
          });
      JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 3));
      p1.add(msg1);
      JPanel p2 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 3));
      p2.add(msg2);
      JPanel p3 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 3));
      p3.add(cb);
      JPanel box = new JPanel();
      box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
      box.add(p1);
      box.add(p2);
      box.add(p3);
      box.setBorder(BorderFactory.createEmptyBorder(0, 0, 11, 11));

      int option =
          JOptionPane.showConfirmDialog(
              SwingUtilities.getWindowAncestor(getUI()),
              new Object[] {box},
              ClientContext.getFrameTitle(getName()),
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              ClientContext.getImageIcon("about_32.gif"));

      if (option != JOptionPane.YES_OPTION) {
        return;
      }
    }

    PatientModel patient = selectedLabo.getPatient();
    PatientVisitModel pvt = new PatientVisitModel();
    pvt.setNumber(number++);
    pvt.setPatientModel(patient);

    // 受け付けを通していないので診療科はユーザ登録してあるものを使用する
    // 診療科名、診療科コード、医師名、医師コード、JMARI
    // 2.0
    pvt.setDeptName(Project.getUserModel().getDepartmentModel().getDepartmentDesc());
    pvt.setDeptCode(Project.getUserModel().getDepartmentModel().getDepartment());
    pvt.setDoctorName(Project.getUserModel().getCommonName());
    if (Project.getUserModel().getOrcaId() != null) {
      pvt.setDoctorId(Project.getUserModel().getOrcaId());
    } else {
      pvt.setDoctorId(Project.getUserModel().getUserId());
    }
    pvt.setJmariNumber(Project.getString(Project.JMARI_CODE));

    // カルテコンテナを生成する
    getContext().openKarte(pvt);
  }

  /**
   * 検索結果件数を設定しステータスパネルへ表示する。
   *
   * @param cnt 件数
   */
  public void updateCount() {
    int count = getTableModel().getObjectCount();
    String text = String.valueOf(count);
    text += "件";
    view.getCountLbl().setText(text);
  }

  /** メニューを制御する */
  private void controlMenu() {

    PatientModel pvt = getSelectedLabo() != null ? getSelectedLabo().getPatient() : null;

    boolean enabled = canOpen(pvt);
    getContext().enabledAction(GUIConst.ACTION_OPEN_KARTE, enabled);
  }

  /**
   * カルテを開くことが可能かどうかを返す。
   *
   * @return 開くことが可能な時 true
   */
  private boolean canOpen(PatientModel patient) {
    if (patient == null) {
      return false;
    }

    if (isKarteOpened(patient)) {
      return false;
    }

    return true;
  }

  /**
   * カルテがオープンされているかどうかを返す。
   *
   * @return オープンされている時 true
   */
  private boolean isKarteOpened(PatientModel patient) {
    if (patient != null) {
      boolean opened = false;
      java.util.List<ChartImpl> allCharts = ChartImpl.getAllChart();
      for (ChartImpl chart : allCharts) {
        if (chart.getPatient().getId() == patient.getId()) {
          opened = true;
          break;
        }
      }
      return opened;
    }
    return false;
  }

  /** 検査結果ファイルを選択し、パースする。 */
  private void selectAndParseLabFile() {

    // 検査結果ファイルを選択する
    JFileChooser chooser = new JFileChooser();
    FileNameExtensionFilter filter =
        new FileNameExtensionFilter(
            "Lab Result File", "DAT", "dat", "DAT2", "dat2", "HL7", "hl7", "TXT", "txt");
    chooser.setFileFilter(filter);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    int returnVal = chooser.showOpenDialog(getUI());

    if (returnVal != JFileChooser.APPROVE_OPTION) {
      return;
    }

    // パースしてテーブルへ表示する
    // 登録ボタンをアクティブにする
    final File labFile = new File(chooser.getSelectedFile().getPath());

    final javax.swing.SwingWorker worker =
        new javax.swing.SwingWorker<List<NLaboImportSummary>, Void>() {

          @Override
          protected List<NLaboImportSummary> doInBackground() throws Exception {

            LabResultParser parse = LabParserFactory.getParser(labFile.getName());

            List<NLaboImportSummary> dataList = parse.parse(labFile);

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

              List<String> idList = new ArrayList<String>(dataList.size());
              for (NLaboImportSummary sm : dataList) {
                idList.add(sm.getPatientId());
              }

              LaboDelegater laboDelegater = new LaboDelegater();
              List<PatientLiteModel> pList = laboDelegater.getConstrainedPatients(idList);

              // for (int i = 0; i < pList.size(); i++) {
              for (int i = 0; i < dataList.size(); i++) {
                NLaboImportSummary sm = dataList.get(i);
                PatientLiteModel pl = pList.get(i);
                if (pl != null) {
                  sm.setKarteId(pl.getPatientId());
                  sm.setKarteBirthday(pl.getBirthday());
                  sm.setKarteKanaName(pl.getKanaName());
                  sm.setKarteName(pl.getFullName());
                  sm.setKarteSex(pl.getGenderDesc());
                }
              }
            }

            return dataList;
          }

          @Override
          protected void done() {

            try {
              List<NLaboImportSummary> allModules = get();
              getTableModel().setDataProvider(allModules);

            } catch (Throwable e) {
              e.printStackTrace(System.err);
              String why = e.getMessage();
              Window parent = SwingUtilities.getWindowAncestor(getUI());
              StringBuilder sb = new StringBuilder();
              sb.append("登録できないファイルがあります。").append("\n");
              sb.append("検査結果ファイルに誤りがある可能性があります。").append("\n");
              sb.append(why);
              String message = sb.toString();
              String title = "ラボレシーバ";
              JOptionPane.showMessageDialog(
                  parent, message, ClientContext.getFrameTitle(title), JOptionPane.WARNING_MESSAGE);
            }
          }
        };

    worker.addPropertyChangeListener(
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getNewValue().equals(javax.swing.SwingWorker.StateValue.STARTED)) {
              getProgressBar().setIndeterminate(true);
            } else if (evt.getNewValue().equals(javax.swing.SwingWorker.StateValue.DONE)) {
              getProgressBar().setIndeterminate(false);
              getProgressBar().setValue(0);
              worker.removePropertyChangeListener(this);
            }
          }
        });

    worker.execute();
  }

  /** パースした検査結果を登録する。 */
  private void addLabtest() {

    final List<NLaboImportSummary> modules = getTableModel().getDataProvider();

    final javax.swing.SwingWorker worker =
        new javax.swing.SwingWorker<Void, Void>() {

          @Override
          protected Void doInBackground() throws Exception {

            LaboDelegater laboDelegater = new LaboDelegater();

            for (NLaboImportSummary summary : modules) {

              PatientModel pm = laboDelegater.putNLaboModule(summary.getModule());

              if (pm != null) {
                summary.setPatient(pm);
                summary.setResult(SUCCESS);

              } else {
                summary.setResult(ERROR);
              }

              // Table 更新
              Runnable awt =
                  new Runnable() {
                    @Override
                    public void run() {
                      getTableModel().fireTableDataChanged();
                    }
                  };
              EventQueue.invokeLater(awt);
            }

            return null;
          }
        };

    worker.addPropertyChangeListener(
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getNewValue().equals(javax.swing.SwingWorker.StateValue.STARTED)) {
              getProgressBar().setIndeterminate(true);
            } else if (evt.getNewValue().equals(javax.swing.SwingWorker.StateValue.DONE)) {
              getProgressBar().setIndeterminate(false);
              getProgressBar().setValue(0);
              worker.removePropertyChangeListener(this);
            }
          }
        });

    worker.execute();
  }

  /** コンポーンントにリスナを登録し接続する。 */
  private void connect() {

    // ファイル選択ボタン
    view.getFileBtn()
        .addActionListener(
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                // ファイル選択
                selectAndParseLabFile();
              }
            });

    // 登録ボタン
    view.getAddBtn()
        .addActionListener(
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                // 検査結果登録
                view.getAddBtn().setEnabled(false);
                addLabtest();
              }
            });
    view.getAddBtn().setEnabled(false);

    // クリアボタン
    view.getClearBtn()
        .addActionListener(
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                // 検査結果登録
                getTableModel().setDataProvider(null);
              }
            });
    view.getClearBtn().setEnabled(false);

    // 行選択
    view.getTable()
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {

              @Override
              public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting() == false) {
                  NLaboImportSummary lab =
                      getTableModel().getObject(view.getTable().getSelectedRow());
                  if (lab != null) {
                    setSelectedLabo(lab);
                  }
                }
              }
            });

    // ダブルクリック
    view.getTable()
        .addMouseListener(
            new MouseAdapter() {

              @Override
              public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                  NLaboImportSummary lab =
                      getTableModel().getObject(view.getTable().getSelectedRow());
                  if (lab != null && lab.getPatient() != null) {
                    openKarte();
                  }
                }
              }
            });

    // コンテキストメニューリスナを設定する
    view.getTable()
        .addMouseListener(
            new MouseAdapter() {

              @Override
              public void mousePressed(MouseEvent e) {
                mabeShowPopup(e);
              }

              @Override
              public void mouseReleased(MouseEvent e) {
                mabeShowPopup(e);
              }

              private void mabeShowPopup(MouseEvent e) {

                if (e.isPopupTrigger()) {

                  final JPopupMenu contextMenu = new JPopupMenu();

                  JTable table = view.getTable();
                  int row = table.rowAtPoint(e.getPoint());
                  Object obj = (Object) getTableModel().getObject(row);
                  int selected = table.getSelectedRow();

                  if (row == selected && obj != null) {
                    String pop1 = ClientContext.getString("watingList.popup.openKarte");
                    contextMenu.add(
                        new JMenuItem(
                            new ReflectAction(pop1, NLaboTestImporter.this, "openKarte")));
                  }
                  contextMenu.show(e.getComponent(), e.getX(), e.getY());
                }
              }
            });

    // data 件数リスナ
    getTableModel()
        .addPropertyChangeListener(
            new PropertyChangeListener() {

              @Override
              public void propertyChange(PropertyChangeEvent evt) {
                List<NLaboImportSummary> list = (List<NLaboImportSummary>) evt.getNewValue();
                boolean enabled = (list != null && list.size() > 0) ? true : false;
                boolean clearOk = enabled;
                if (enabled) {
                  for (NLaboImportSummary sm : list) {
                    if (sm.getKarteId() == null) {
                      enabled = false;
                      break;
                    }
                  }
                }
                view.getAddBtn().setEnabled(enabled);
                view.getClearBtn().setEnabled(clearOk);
                updateCount();
              }
            });
  }

  /** GUI コンポーネントを初期化する。 */
  private void initComponents() {

    view = new NLabTestImportView();
    setUI(view);

    String[] columnNames =
        new String[] {"ラボ", "患者ID", "カナ", "カルテ・カナ", "性別", "カルテ・性別", "検体採取日", "項目数", "登録"};
    String[] propNames =
        new String[] {
          "laboCode",
          "patientId",
          "patientName",
          "karteKanaName",
          "patientSex",
          "karteSex",
          "sampleDate",
          "numOfTestItems",
          "result"
        };
    int[] columnWidth = new int[] {50, 120, 120, 120, 50, 70, 120, 50, 80};

    tableModel = new ListTableModel<NLaboImportSummary>(columnNames, 30, propNames, null);
    view.getTable().setModel(tableModel);
    view.getTable().setRowHeight(ClientContext.getHigherRowHeight());
    view.getTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    view.getTable().setTransferHandler(new NLaboTestFileTransferHandler(this));

    // カラム幅を変更する
    for (int i = 0; i < columnWidth.length; i++) {
      view.getTable().getColumnModel().getColumn(i).setPreferredWidth(columnWidth[i]);
    }

    // レンダラを設定する
    view.getTable().setDefaultRenderer(Object.class, new NLaboTestImporter.LabTestRenderer());

    // カウント値0を設定する
    updateCount();
  }

  protected class LabTestRenderer extends DefaultTableCellRenderer {

    /** Creates new IconRenderer */
    public LabTestRenderer() {
      super();
    }

    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean isFocused, int row, int col) {

      NLaboImportSummary summary = (NLaboImportSummary) tableModel.getObject(row);

      if (isSelected) {
        this.setBackground(table.getSelectionBackground());
        this.setForeground(table.getSelectionForeground());

      } else {
        if (summary != null && summary.getKarteId() == null) {

          this.setBackground(UNCONSTRAINED_COLOR);

        } else {

          if ((row & (1)) == 0) {
            this.setBackground(EVEN_COLOR);
          } else {
            this.setBackground(ODD_COLOR);
          }
        }

        this.setForeground(table.getForeground());
      }

      if (value != null && value instanceof String) {
        this.setText((String) value);
      } else {
        this.setText(value == null ? "" : value.toString());
      }
      return this;
    }
  }
}
Ejemplo n.º 7
0
  /** GUI コンポーネントを初期化する。 */
  private void initComponents() {

    // View
    view = new PatientSearchView();
    setUI(view);

    // ColumnSpecHelperにテーブルを設定する
    columnHelper.setTable(view.getTable());

    // ------------------------------------------
    // View のテーブルモデルを置き換える
    // ------------------------------------------
    String[] columnNames = columnHelper.getTableModelColumnNames();
    String[] methods = columnHelper.getTableModelColumnMethods();
    Class[] cls = columnHelper.getTableModelColumnClasses();

    tableModel =
        new ListTableModel<PatientModel>(columnNames, 0, methods, cls) {

          @Override
          public Object getValueAt(int row, int col) {

            Object ret = null;

            if (col == ageColumn && ageDisplay) {

              PatientModel p = getObject(row);

              if (p != null) {
                int showMonth = Project.getInt("ageToNeedMonth", 6);
                ret = AgeCalculater.getAgeAndBirthday(p.getBirthday(), showMonth);
              }
            } else {

              ret = super.getValueAt(row, col);
            }

            return ret;
          }
        };
    view.getTable().setModel(tableModel);

    // masuda^   table sorter 組み込み
    sorter = new ListTableSorter(tableModel);
    view.getTable().setModel(sorter);
    sorter.setTableHeader(view.getTable().getTableHeader());
    // masuda$
    // カラム幅更新
    columnHelper.updateColumnWidth();
    // minagawa^ lsctest
    view.getTable().getColumnModel().getColumn(stateColumn).setIdentifier(COLUMN_IDENTIFIER_STATE);
    // minagawa$

    // masuda^
    // レンダラを設定する
    // view.getTable().setDefaultRenderer(Object.class, new OddEvenRowRenderer());
    // 連ドラ、梅ちゃん先生
    PatientListTableRenderer renderer = new PatientListTableRenderer();
    renderer.setTable(view.getTable());
    renderer.setDefaultRenderer();
    // masuda$

    // ソートアイテム
    sortItem = Project.getInt("sortItem", 0);
    // s.oh^ 2014/08/13 コントロールサイズ調整
    String nimbus = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
    String laf = UIManager.getLookAndFeel().getClass().getName();
    if (!laf.equals(nimbus)) {
      view.getSortItem().setPreferredSize(new Dimension(90, 20));
    }
    // s.oh$
    view.getSortItem().setSelectedIndex(sortItem);

    // Auto IME Windows の時のみ
    if (!ClientContext.isMac()) {
      // デフォルトは true
      boolean autoIme = Project.getBoolean("autoIme", true);
      view.getAutoIme().setSelected(autoIme);
    } else {
      // MAC は disabled
      // view.getAutoIme().setEnabled(false);
      view.getAutoIme().setVisible(false);
    }

    // 行高
    if (ClientContext.isWin()) {
      view.getTable().setRowHeight(ClientContext.getMoreHigherRowHeight());
    } else {
      view.getTable().setRowHeight(ClientContext.getHigherRowHeight());
    }

    String method = ageDisplay ? AGE_METHOD[0] : AGE_METHOD[1];
    ListTableModel tModel = getTableModel();
    tModel.setProperty(method, ageColumn);
    List<ColumnSpec> columnSpecs = columnHelper.getColumnSpecs();
    for (int i = 0; i < columnSpecs.size(); i++) {
      ColumnSpec cs = columnSpecs.get(i);
      String test = cs.getMethod();
      if (test.toLowerCase().endsWith("birthday")) {
        cs.setMethod(method);
        break;
      }
    }

    //// s.oh^ 2014/10/22 Icon表示
    //        view.getSearchLabel().setIcon(ClientContext.getImageIconArias("icon_search_large"));
    //// s.oh$

    // s.oh^ 2014/04/16 メニュー制御
    view.getTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // s.oh$
  }
Ejemplo n.º 8
0
/**
 * StmapTreeMenuBuilder
 *
 * @author Kazushi Minagawa
 */
public class StmapTreePopupBuilder {

  // minagawa^ Icon Server
  // private static final Icon icon = ClientContext.getImageIcon("foldr_16.gif");
  private static final Icon icon = ClientContext.getImageIconArias("icon_foldr_small");
  // minagawa$

  private HashMap<Object, JMenu> parents;
  private JPopupMenu popup;
  private DefaultMutableTreeNode rootNode;

  public StmapTreePopupBuilder() {}

  public void build(
      StampTree stampTree, JPopupMenu popup, JComponent cmp, TransferHandler handler) {

    if (parents == null) {
      parents = new HashMap<Object, JMenu>(10, 0.75f);
    } else {
      parents.clear();
    }

    this.popup = popup;

    rootNode = (DefaultMutableTreeNode) stampTree.getModel().getRoot();
    Enumeration e = rootNode.preorderEnumeration();
    e.nextElement(); // consume root

    while (e.hasMoreElements()) {
      parseChildren((StampTreeNode) e.nextElement(), cmp, handler);
    }
  }

  private void parseChildren(StampTreeNode node, JComponent comp, TransferHandler handler) {

    if (!node.isLeaf()) {
      JMenu subMenu = new JMenu(node.getUserObject().toString());
      DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
      if (parentNode == rootNode) {
        popup.add(subMenu);
      } else {
        JMenu parent = parents.get(node.getParent());
        parent.add(subMenu);
      }
      parents.put(node, subMenu);

      // 配下の子を全て列挙しJmenuItemにまとめる
      JMenuItem item = new JMenuItem(node.getUserObject().toString());
      item.setIcon(icon);
      subMenu.add(item);

      if (comp != null && handler != null) {
        item.addActionListener(
            new TransferAction(comp, handler, new LocalStampTreeNodeTransferable(node)));
      } else {
        item.setEnabled(false);
      }

    } else {
      ModuleInfoBean info = (ModuleInfoBean) node.getUserObject();
      JMenuItem item = new JMenuItem(info.getStampName());
      if (comp != null && handler != null) {
        item.addActionListener(
            new TransferAction(comp, handler, new LocalStampTreeNodeTransferable(node)));
      } else {
        item.setEnabled(false);
      }
      DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
      if (parentNode == rootNode) {
        popup.add(item);
      } else {
        JMenu parent = parents.get(node.getParent());
        parent.add(item);
      }
    }
  }
}
  @Override
  public String create() {

    try {
      Document document =
          new Document(
              PageSize.A4, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());

      String path =
          UserDocumentHelper.createPathToDocument(
              getDocumentDir(), // PDF File を置く場所
              "診断書", // 文書名
              EXT_PDF, // 拡張子
              model.getPatientName(), // 患者氏名
              new Date()); // 日付
      // minagawa^ jdk7
      Path pathObj = Paths.get(path);
      setPathToPDF(pathObj.toAbsolutePath().toString()); // 呼び出し側で取り出せるように保存する
      // minagawa$
      // Open Document
      ByteArrayOutputStream byteo = new ByteArrayOutputStream();
      PdfWriter.getInstance(document, byteo);
      document.open();

      // Font
      baseFont = BaseFont.createFont(HEISEI_MIN_W3, UNIJIS_UCS2_HW_H, false);
      if (Project.getString(Project.SHINDANSYO_FONT_SIZE).equals("small")) {
        titleFont = new Font(baseFont, getTitleFontSize());
        bodyFont = new Font(baseFont, getBodyFontSize());
      } else {
        titleFont = new Font(baseFont, 18);
        bodyFont = new Font(baseFont, 14);
      }

      // ----------------------------------------
      // タイトル
      // ----------------------------------------
      Paragraph para = new Paragraph(DOC_TITLE, titleFont);
      para.setAlignment(Element.ALIGN_CENTER);
      document.add(para);
      document.add(new Paragraph(" "));
      document.add(new Paragraph(" "));
      document.add(new Paragraph(" "));

      // ----------------------------------------
      // 患者情報テーブル
      // ----------------------------------------
      PdfPTable pTable = new PdfPTable(new float[] {20.0f, 60.0f, 10.0f, 10.0f});
      pTable.setWidthPercentage(100.0f);

      // 患者氏名
      PdfPCell cell;
      pTable.addCell(createNoBorderCell("氏  名"));
      cell = createNoBorderCell(model.getPatientName());
      cell.setColspan(3);
      pTable.addCell(cell);

      // 生年月日 性別
      pTable.addCell(createNoBorderCell("生年月日"));
      pTable.addCell(createNoBorderCell(getDateString(model.getPatientBirthday())));
      pTable.addCell(createNoBorderCell("性別"));
      pTable.addCell(createNoBorderCell(model.getPatientGender()));

      // 住所
      pTable.addCell(createNoBorderCell("住  所"));
      cell = createNoBorderCell(model.getPatientAddress());
      cell.setColspan(3);
      pTable.addCell(cell);

      // 傷病名
      String disease = model.getItemValue(MedicalCertificateImpl.ITEM_DISEASE);
      pTable.addCell(createNoBorderCell("傷 病 名"));
      cell = createNoBorderCell(disease);
      cell.setColspan(3);
      pTable.addCell(cell);

      document.add(pTable);
      document.add(new Paragraph(" "));

      // ------------------------------------------
      // コンテントテーブル
      // ------------------------------------------
      pTable = new PdfPTable(new float[] {1.0f});
      pTable.setWidthPercentage(100.0f);
      String informed = model.getTextValue(MedicalCertificateImpl.TEXT_INFORMED_CONTENT);
      cell = createNoBorderCell(informed);
      if (Project.getString("sindansyo.font.size").equals("small")) {
        cell.setFixedHeight(250.0f); // Cell 高
      } else {
        cell.setFixedHeight(225.0f); // Cell 高
      }
      cell.setLeading(0f, 1.5f); // x 1.5 font height
      pTable.addCell(cell);
      document.add(pTable);
      document.add(new Paragraph(" "));

      // ------------------------------------------
      // 署名テーブル
      // ------------------------------------------
      // 日付
      pTable = new PdfPTable(new float[] {1.0f});
      pTable.setWidthPercentage(100.0f);

      // 上記の通り診断する
      pTable.addCell(createNoBorderCell("上記の通り診断する。"));
      // minagawa^ LSC 1.4 bug fix 文書の印刷日付 2013/06/24
      // String dateStr = getDateString(model.getConfirmed());
      String dateStr = getDateString(model.getStarted());
      // minagawa$
      pTable.addCell(createNoBorderCell(dateStr));

      // 住所 BaseFont.getWidthPoint
      String zipCode = model.getConsultantZipCode();
      String address = model.getConsultantAddress();
      //            float zipLen = baseFont.getWidthPoint(zipCode, 12.0f);
      //            float addressLen = baseFont.getWidthPoint(address, 12.0f);
      //            float padlen = addressLen-zipLen;
      //            sb = new StringBuilder();
      //            while (true) {
      //                sb.append(" ");
      //                if (baseFont.getWidthPoint(sb.toString(), 12.0f)>=padlen) {
      //                    break;
      //                }
      //            }
      //            String space = sb.toString();
      StringBuilder sb = new StringBuilder();
      sb.append(zipCode);
      cell = createNoBorderCell(sb.toString());
      cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
      pTable.addCell(cell);

      sb = new StringBuilder();
      sb.append(address);
      cell = createNoBorderCell(sb.toString());
      cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
      pTable.addCell(cell);

      // 病院名
      cell = createNoBorderCell(model.getConsultantHospital());
      cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
      pTable.addCell(cell);

      // 電話番号
      cell = createNoBorderCell(model.getConsultantTelephone());
      cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
      pTable.addCell(cell);

      // 医師
      sb = new StringBuilder();
      sb.append("医 師 ").append(model.getConsultantDoctor()).append(" 印");
      cell = createNoBorderCell(sb.toString());
      cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
      pTable.addCell(cell);
      document.add(pTable);

      document.close();

      // // pdf content bytes
      byte[] pdfbytes = byteo.toByteArray();

      // 評価でない場合は Fileへ書き込んでリターン
      if (!ClientContext.is5mTest()) {
        // minagawa^
        //                FileOutputStream fout = new FileOutputStream(pathToPDF);
        //                FileChannel channel = fout.getChannel();
        //                ByteBuffer bytebuff = ByteBuffer.wrap(pdfbytes);
        //
        //                while(bytebuff.hasRemaining()) {
        //                    channel.write(bytebuff);
        //                }
        //                channel.close();
        Files.write(pathObj, pdfbytes);
        // minagawa$
        return getPathToPDF();
      }

      // 評価の場合は water Mark を書く
      PdfReader pdfReader = new PdfReader(pdfbytes);
      // minagawa~
      //            PdfStamper pdfStamper = new PdfStamper(pdfReader,new
      // FileOutputStream(pathToPDF));
      PdfStamper pdfStamper = new PdfStamper(pdfReader, Files.newOutputStream(pathObj));
      // minagawa$
      Image image = Image.getInstance(ClientContext.getImageResource("water-mark.png"));

      for (int i = 1; i <= pdfReader.getNumberOfPages(); i++) {

        PdfContentByte content = pdfStamper.getUnderContent(i);
        image.scaleAbsolute(PageSize.A4.getWidth(), PageSize.A4.getHeight());
        image.setAbsolutePosition(0.0f, 0.0f);

        content.addImage(image);
      }

      pdfStamper.close();

      return getPathToPDF();

    } catch (IOException ex) {
      ClientContext.getBootLogger().warn(ex);
      throw new RuntimeException(ERROR_IO);
    } catch (DocumentException ex) {
      ClientContext.getBootLogger().warn(ex);
      throw new RuntimeException(ERROR_PDF);
    }
  }
Ejemplo n.º 10
0
 /** Creates a new instance of SettingPanel */
 public AbstractSettingPanel() {
   ui = new JPanel();
   logger = ClientContext.getBootLogger();
 }
/**
 * 院内検査を登録するダイアログ
 *
 * @author masuda, Masuda Naika
 */
public class InFacilityLabo {

  private static final char FULL_MINUS = (char) 65293;
  private static final char HALF_MINUS = '-';

  private static final char[] MATCHIES = {
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ', '.', 'ー', FULL_MINUS
  };
  private static final char[] REPLACES = {
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ', '.', HALF_MINUS, HALF_MINUS
  };

  private static final String[] TEMPLATE_COL_NAME = {"検査項目"};
  private static final String[] TEMPLATE_COL_METHOD = {"getItemName"};
  private static final int[] TEMPLATE_COL_WIDTH = {20};
  private static final int START_NUM_ROW = 1;

  private static final String[] SET_COL_NAME = {"検査項目", "値", "異常", "基準値", "単位"};
  private static final String[] SET_COL_METHOD = {
    "getItemName", "getItemValue", "getAbnormalFlg", "getNormalValue", "getUnit"
  };
  private static final int[] SET_COL_WIDTH = {20, 10, 10, 20, 10};
  private static final int VALUE_COL = 1;
  private static final int NORMAL_COL = 3;
  private static final int UNIT_COL = 4;

  private static final ImageIcon closeIcon = ClientContext.getImageIconAlias("icon_cancel_small");
  private static final ImageIcon deleteIcon = ClientContext.getImageIconAlias("icon_delete_small");
  private static final ImageIcon saveIcon = ClientContext.getImageIconAlias("icon_save_small");

  private static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm";

  private JDialog dialog;
  private JPanel panel;
  private JTextField dateFld;
  private JTable setTable;
  private JTable templateTable;
  private JCheckBox editCheck;
  private JButton deleteBtn;
  private JButton closeBtn;
  private JButton saveBtn;
  private JPanel centerPanel;
  private JScrollPane rtScroll;

  private ListTableModel<InFacilityLaboItem> setTableModel;
  private ListTableModel<InFacilityLaboItem> templateTableModel;

  private Chart chart;
  private boolean male;
  private boolean toUpdate;

  public void setContext(Chart chart) {
    this.chart = chart;
    male = IInfoModel.MALE.equals(chart.getPatient().getGender());
  }

  public boolean start() throws Exception {

    initComponents();
    connect();
    setupTables();
    dialog.setVisible(true);

    dialog.dispose();

    return toUpdate;
  }

  private void setupTables() throws Exception {

    templateTableModel =
        new ListTableModel<InFacilityLaboItem>(
            TEMPLATE_COL_NAME, START_NUM_ROW, TEMPLATE_COL_METHOD, null) {

          @Override
          public boolean isCellEditable(int row, int column) {
            return false;
          }
        };

    setTableModel =
        new ListTableModel<InFacilityLaboItem>(SET_COL_NAME, START_NUM_ROW, SET_COL_METHOD, null) {
          @Override
          public boolean isCellEditable(int row, int column) {
            if (column == VALUE_COL || column == NORMAL_COL || column == UNIT_COL) {
              return true;
            }
            return false;
          }

          @Override
          public void setValueAt(Object obj, int row, int column) {

            if (column != VALUE_COL && column != NORMAL_COL && column != UNIT_COL) {
              return;
            }
            InFacilityLaboItem item = (InFacilityLaboItem) setTableModel.getObject(row);
            String value = (String) obj;
            value = toHalfNumber(value).trim();
            switch (column) {
              case VALUE_COL:
                item.setItemValue(value);
                break;
              case NORMAL_COL:
                item.setNormalValue(value);
                break;
              case UNIT_COL:
                item.setUnit(value);
                break;
            }
            item.setAbnormalFlg(getAbnormalFlg(item));
          }
        };

    List<InFacilityLaboItem> defaultList = InFacilityLaboTable.createLaboItemList();
    templateTableModel.setDataProvider(defaultList);
    templateTable.setModel(templateTableModel);
    StripeTableCellRenderer renderer = new StripeTableCellRenderer(templateTable);
    renderer.setDefaultRenderer();
    templateTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    templateTable.getTableHeader().setReorderingAllowed(false);
    // 列幅を設定する
    int len = TEMPLATE_COL_NAME.length;
    TableColumn column;
    for (int i = 0; i < len; i++) {
      column = templateTable.getColumnModel().getColumn(i);
      column.setPreferredWidth(TEMPLATE_COL_WIDTH[i]);
    }
    templateTable.setDragEnabled(true);
    InFacilityLaboTransferHandler tHandler = new InFacilityLaboTransferHandler();
    tHandler.setEditable(false);
    templateTable.setTransferHandler(tHandler);

    MasudaDelegater del = MasudaDelegater.getInstance();
    List<InFacilityLaboItem> facilityList = del.getInFacilityLaboItemList();
    setTableModel.setDataProvider(facilityList);
    setTable.setModel(setTableModel);
    renderer = new StripeTableCellRenderer(setTable);
    renderer.setDefaultRenderer();
    setTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    setTable.getTableHeader().setReorderingAllowed(false);
    // 列幅を設定する
    len = SET_COL_NAME.length;
    for (int i = 0; i < len; i++) {
      column = setTable.getColumnModel().getColumn(i);
      column.setPreferredWidth(SET_COL_WIDTH[i]);
    }
    setTable.setDragEnabled(true);
    setTable.setDropMode(DropMode.INSERT_ROWS);
    setTable.setColumnSelectionAllowed(false);
    setTable.setCellSelectionEnabled(true);
    InFacilityLaboTransferHandler sHandler = new InFacilityLaboTransferHandler();
    sHandler.setEditable(true);
    setTable.setTransferHandler(sHandler);
    setTable.addMouseMotionListener(new SetTableMouseMotionListener());
  }

  private void initComponents() {

    final SimpleDateFormat dateFrmt = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
    panel = new JPanel();
    panel.setLayout(new BorderLayout());
    JPanel north = new JPanel();
    north.setLayout(new BoxLayout(north, BoxLayout.X_AXIS));
    JLabel dateLbl = new JLabel("検査日:");
    north.add(dateLbl);
    dateFld = new JTextField(10);
    dateFld.setMaximumSize(dateFld.getPreferredSize());
    dateFld.setEditable(false);
    dateFld.setText(dateFrmt.format(new Date()));
    north.add(dateFld);
    north.add(Box.createHorizontalGlue());
    editCheck = new JCheckBox("項目編集");
    north.add(editCheck);
    panel.add(north, BorderLayout.NORTH);

    JPanel south = new JPanel();
    south.setLayout(new FlowLayout());
    deleteBtn = new JButton("削除", deleteIcon);
    deleteBtn.setEnabled(false);
    south.add(deleteBtn);
    closeBtn = new JButton("閉じる", closeIcon);
    south.add(closeBtn);
    saveBtn = new JButton("保存", saveIcon);
    south.add(saveBtn);
    panel.add(south, BorderLayout.SOUTH);

    setTable = new JTable();
    JScrollPane scroll = new JScrollPane(setTable);
    centerPanel = new JPanel();
    centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.X_AXIS));
    centerPanel.add(scroll);
    panel.add(centerPanel, BorderLayout.CENTER);

    templateTable = new JTable();
    templateTable.setToolTipText("DnDで左の施設内検査項目テーブルに追加してください。");
    rtScroll = new JScrollPane(templateTable);
    Dimension d = new Dimension(200, 200);
    rtScroll.setPreferredSize(d);
    d = new Dimension(200, Integer.MAX_VALUE);
    rtScroll.setMaximumSize(d);

    dialog = new JDialog();
    String title = ClientContext.getFrameTitle("院内検査項目追加");
    dialog.setTitle(title);
    dialog.setModal(true);
    dialog.setContentPane(panel);
    ClientContext.setDolphinIcon(dialog);

    dialog.pack();
    dialog.setLocationRelativeTo(chart.getFrame());
  }

  private void connect() {

    editCheck.addItemListener(
        new ItemListener() {

          @Override
          public void itemStateChanged(ItemEvent e) {
            if (editCheck.isSelected()) {
              deleteBtn.setEnabled(true);
              centerPanel.add(rtScroll);
            } else {
              deleteBtn.setEnabled(false);
              centerPanel.remove(rtScroll);
            }
            dialog.pack();
          }
        });

    deleteBtn.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            delete();
          }
        });

    closeBtn.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
          }
        });

    saveBtn.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              save();
              toUpdate = true;
            } catch (Exception ex) {
            }
          }
        });

    // カレンダによる日付入力を設定する
    PopupListener pl = new PopupListener(dateFld);
  }

  private void delete() {
    int[] selectedRows = setTable.getSelectedRows();
    for (int i = selectedRows.length - 1; i >= 0; --i) {
      setTableModel.deleteAt(selectedRows[i]);
    }
  }

  private void save() throws Exception {

    @SuppressWarnings("unchecked")
    List<InFacilityLaboItem> list = setTableModel.getDataProvider();
    // laboCode(facilityId)を設定する
    String fid = Project.getFacilityId();
    for (InFacilityLaboItem item : list) {
      item.setLaboCode(fid);
    }
    // まずは施設内検査項目を登録する。
    MasudaDelegater del = MasudaDelegater.getInstance();
    del.updateInFacilityLaboItemList(list);

    // ついでNLaboModuleを登録する。
    String pid = chart.getPatient().getPatientId();
    String fidPid = fid + ":" + pid;
    String ptName = chart.getPatient().getFullName();
    String sampleDate = dateFld.getText().trim();
    // 検査箋(検査モジュール)のキー = patientId.sampleDate.labCode
    StringBuilder buf = new StringBuilder();
    buf.append(pid);
    buf.append(".");
    buf.append(sampleDate);
    buf.append(".");
    buf.append(fid);
    String testKey = buf.toString();

    // NLaboModuleを作成
    NLaboModule nLaboModule = new NLaboModule();

    // NLaboItemを作成
    List<NLaboItem> nLaboItemList = new ArrayList<>();
    for (InFacilityLaboItem item : list) {
      String itemValue = item.getItemValue();
      if (itemValue == null || itemValue.trim().isEmpty()) {
        continue;
      }
      NLaboItem nLaboItem = createNLaboItem(item);
      nLaboItem.setPatientId(fidPid);
      nLaboItem.setLaboCode(fid);
      nLaboItem.setSampleDate(sampleDate);
      nLaboItem.setLaboModule(nLaboModule);
      nLaboItemList.add(nLaboItem);
    }
    // 空ならリターン
    if (nLaboItemList.isEmpty()) {
      return;
    }

    // NLaboModuleに情報設定
    nLaboModule.setPatientId(pid); // ここはただのPatientID
    nLaboModule.setPatientName(ptName);
    nLaboModule.setPatientSex(male ? "M" : "F");
    nLaboModule.setSampleDate(sampleDate);
    nLaboModule.setLaboCenterCode(fid);
    nLaboModule.setModuleKey(testKey);
    nLaboModule.setReportFormat("NLab");
    // nLaboModule.setNumOfItems(String.valueOf(nLaboItemList.size()));
    nLaboModule.setItems(nLaboItemList);

    // NLaboModuleをデータベースに登録する
    LaboDelegater ldel = LaboDelegater.getInstance();
    ldel.postNLaboModule(nLaboModule);
  }

  private NLaboItem createNLaboItem(InFacilityLaboItem item) {

    NLaboItem nLaboItem = new NLaboItem();
    nLaboItem.setItemCode(item.getMedisCode());
    nLaboItem.setItemName(item.getItemName());
    nLaboItem.setMedisCode(item.getMedisCode());
    nLaboItem.setParentCode(item.getParentCode());
    nLaboItem.setGroupCode(item.getGroupCode());
    nLaboItem.setGroupName(item.getGroupName());
    nLaboItem.setLaboCode(item.getLaboCode());
    nLaboItem.setNormalValue(item.getNormalValue());
    nLaboItem.setSpecimenCode(item.getSpecimenCode());
    nLaboItem.setSpecimenName(item.getSpecimenName());
    nLaboItem.setReportStatus("E");
    nLaboItem.setValue(item.getItemValue());
    nLaboItem.setAbnormalFlg(item.getAbnormalFlg());
    nLaboItem.setUnit(item.getUnit());
    return nLaboItem;
  }

  private String getAbnormalFlg(InFacilityLaboItem item) {
    try {
      float value = Float.valueOf(item.getItemValue());
      String[] strs = item.getNormalValue().split("-");
      String low = strs[0].trim();
      String hi = strs[1].trim();

      if (low.isEmpty()) {
        float hiValue = Float.valueOf(hi);
        if (value > hiValue) {
          return "H";
        }
      } else if (hi.isEmpty()) {
        float lowValue = Float.valueOf(low);
        if (value < lowValue) {
          return "L";
        }
      }
      float hiValue = Float.valueOf(hi);
      float lowValue = Float.valueOf(low);
      if (value < lowValue) {
        return "L";
      } else if (value > hiValue) {
        return "H";
      }

    } catch (Exception e) {
    }
    return null;
  }

  private String toHalfNumber(String test) {
    if (test != null) {
      for (int i = 0; i < MATCHIES.length; i++) {
        test = test.replace(MATCHIES[i], REPLACES[i]);
      }
    }
    return test;
  }

  // MouseMotionListener
  private class SetTableMouseMotionListener implements MouseMotionListener {

    @Override
    public void mouseDragged(MouseEvent e) {
      int ctrlMask = InputEvent.CTRL_DOWN_MASK;
      int action =
          ((e.getModifiersEx() & ctrlMask) == ctrlMask)
              ? TransferHandler.COPY
              : TransferHandler.MOVE;

      JTable setTable = (JTable) e.getSource();
      // 非選択状態からいきなりドラッグを開始すると cellEditor が残ってしまう問題の workaround
      if (setTable.isEditing()) {
        setTable.getCellEditor().stopCellEditing();
      }
      TransferHandler handler = setTable.getTransferHandler();
      handler.exportAsDrag(setTable, e, action);
    }

    @Override
    public void mouseMoved(MouseEvent e) {}
  }

  private static class PopupListener extends PopupCalendarListener {

    public PopupListener(JTextField tf) {
      super(tf);
    }

    @Override
    public void setValue(SimpleDate sd) {
      tf.setText(getFormattedDate(sd));
    }

    private String getFormattedDate(SimpleDate sd) {
      final SimpleDateFormat dateFrmt = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
      GregorianCalendar gc = new GregorianCalendar();
      gc.clear();
      gc.set(sd.getYear(), sd.getMonth(), sd.getDay());
      return dateFrmt.format(gc.getTime());
    }
  }
}