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 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()); }