@Override public List<PatientLiteModel> getConstrainedPatients(String fid, List<String> idList) { List<PatientLiteModel> ret = new ArrayList<PatientLiteModel>(idList.size()); for (String pid : idList) { try { PatientModel patient = (PatientModel) em.createQuery("from PatientModel p where p.facilityId=:fid and p.patientId=:pid") .setParameter("fid", fid) .setParameter("pid", pid) .getSingleResult(); ret.add(patient.patientAsLiteModel()); } catch (NoResultException e) { PatientLiteModel dummy = new PatientLiteModel(); dummy.setFullName("未登録"); dummy.setKanaName("未登録"); dummy.setGender("U"); ret.add(dummy); } } return ret; }
// masuda$ // ChartEventListener @Override public void propertyChange(PropertyChangeEvent pce) { if (tableModel == null) { return; } ChartEventModel evt = (ChartEventModel) pce.getNewValue(); int sRow = -1; long ptPk = evt.getPtPk(); List<PatientModel> list = tableModel.getDataProvider(); // minagawa^ // ChartEventModel.EVENT eventType = evt.getEventType(); int eventType = evt.getEventType(); // minagawa$ switch (eventType) { case ChartEventModel.PVT_STATE: for (int row = 0; row < list.size(); ++row) { PatientModel pm = list.get(row); if (ptPk == pm.getId()) { sRow = row; pm.setOwnerUUID(evt.getOwnerUUID()); break; } } break; case ChartEventModel.PM_MERGE: for (int row = 0; row < list.size(); ++row) { PatientModel pm = list.get(row); if (ptPk == pm.getId()) { sRow = row; // pm = msg.getPatientModel(); list.set(row, evt.getPatientModel()); break; } } break; case ChartEventModel.PVT_MERGE: for (int row = 0; row < list.size(); ++row) { PatientModel pm = list.get(row); if (ptPk == pm.getId()) { sRow = row; // pm = msg.getPatientVisitModel().getPatientModel(); list.set(row, evt.getPatientVisitModel().getPatientModel()); break; } } break; default: break; } if (sRow != -1) { tableModel.fireTableRowsUpdated(sRow, sRow); } }
@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean isFocused, int row, int col) { super.getTableCellRendererComponent(table, value, isSelected, isFocused, row, col); PatientModel pm = (PatientModel) sorter.getObject(row); // minagawa^ lsctest boolean bStateColumn = (view.getTable().getColumnModel().getColumn(col).getIdentifier() != null && view.getTable() .getColumnModel() .getColumn(col) .getIdentifier() .equals(COLUMN_IDENTIFIER_STATE)); // if (pm != null && col == stateColumn) { if (pm != null && bStateColumn) { // minagawa$ setHorizontalAlignment(JLabel.CENTER); if (pm.isOpened()) { if (clientUUID.equals(pm.getOwnerUUID())) { setIcon(WatingListImpl.OPEN_ICON); } else { setIcon(WatingListImpl.NETWORK_ICON); } } else { setIcon(null); } setText(""); } else { setHorizontalAlignment(JLabel.LEFT); setIcon(null); setText(value == null ? "" : value.toString()); } return this; }
/** * カルテがオープンされているかどうかを返す。 * * @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; }
@Override public PatientModel create(String fid, NLaboModule module) { String pid = module.getPatientId(); // 施設IDと LaboModule の患者IDで 患者を取得する PatientModel patient = (PatientModel) em.createQuery("from PatientModel p where p.facilityId=:fid and p.patientId=:pid") .setParameter("fid", fid) .setParameter("pid", pid) .getSingleResult(); // -------------------------------------------------------- if (patient != null) { // 患者の健康保険を取得する List<HealthInsuranceModel> insurances = (List<HealthInsuranceModel>) em.createQuery(QUERY_INSURANCE_BY_PATIENT_PK) .setParameter(PK, patient.getId()) .getResultList(); patient.setHealthInsurances(insurances); } // -------------------------------------------------------- String fidPid = fid + ":" + pid; module.setPatientId(fidPid); // item の patientId を変更する Collection<NLaboItem> items = module.getItems(); for (NLaboItem item : items) { item.setPatientId(fidPid); } // -------------------------------------------------------- // patientId & 検体採取日 & ラボコード で key // これが一致しているモジュールは再報告として削除してから登録する。 // -------------------------------------------------------- String sampleDate = module.getSampleDate(); String laboCode = module.getLaboCenterCode(); String moduleKey = module.getModuleKey(); if (moduleKey != null) { StringBuilder sb = new StringBuilder(); sb.append(pid).append(".").append(sampleDate).append(".").append(laboCode); String test = sb.toString(); if (test.equals(moduleKey)) { sb = new StringBuilder(); sb.append(fid); sb.append(":"); sb.append(moduleKey); moduleKey = sb.toString(); module.setModuleKey(moduleKey); System.err.println("corrected moduke key=" + module.getModuleKey()); } } NLaboModule exist = null; try { if (moduleKey != null) { exist = (NLaboModule) em.createQuery(QUERY_MODULE_BY_MODULE_KEY) .setParameter(MODULEKEY, moduleKey) .getSingleResult(); System.err.println("module did exist"); } else { exist = (NLaboModule) em.createQuery(QUERY_MODULE_BY_PID_SAMPLEDATE_LABCODE) .setParameter(FIDPID, fidPid) .setParameter(SAMPLEDATE, sampleDate) .setParameter(LABOCODE, laboCode) .getSingleResult(); } } catch (Exception e) { exist = null; } // Cascade.TYPE=ALL if (exist != null) { em.remove(exist); System.err.println("module did remove"); } // 永続化する em.persist(module); return patient; }