protected void startProgress() {
   Component c = null;
   if (chart != null && chart.getFrame() != null && chart.getFrame().getGlassPane() != null) {
     c = chart.getFrame().getGlassPane();
   }
   if (c != null && c instanceof BlockGlass) {
     ((BlockGlass) c).setVisible(true);
   }
   chart.getDocumentHistory().blockHistoryTable(true);
   chart.getStatusPanel().getProgressBar().setIndeterminate(true);
 }
  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());
  }
 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);
 }
 public void setContext(Chart chart) {
   this.chart = chart;
   male = IInfoModel.MALE.equals(chart.getPatient().getGender());
 }
  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);
  }