private void loadPatientIdentifiers() { List<IdentifierType> types = PatientManager.getAllIdentifierTypes(getHSession()); identiers = new ArrayList<PatientIdentifier>(); typeLoop: for (IdentifierType type : types) { if (type.isVoided()) continue; for (PatientIdentifier identifier : localPatient.getPatientIdentifiers()) { if (identifier.getType().getId() == type.getId()) { identifier.setValueEdit(identifier.getValue()); identiers.add(identifier); continue typeLoop; } } // create new identifier if the patient doesn't already have on for this type PatientIdentifier identifier = new PatientIdentifier(); identifier.setType(type); identifier.setValueEdit(EMPTY); identifier.setPatient(localPatient); identiers.add(identifier); } tblViewer.setInput(identiers); }
@Override protected void setValue(Object element, Object value) { PatientIdentifier model = (PatientIdentifier) element; model.setValueEdit(((String) value).trim().toUpperCase()); getViewer().update(element, null); }
@Override protected Object getValue(Object element) { PatientIdentifier model = (PatientIdentifier) element; return model.getValueEdit(); }
private boolean fieldsOk() { boolean allEmpty = true; for (PatientIdentifier newId : identiers) { if (newId.getValueEdit() == null || newId.getValueEdit().isEmpty()) continue; allEmpty = false; String illegalText = iDARTUtil.checkPatientId(newId.getValueEdit()); if (illegalText != null) { showMessage( MessageDialog.ERROR, MessageFormat.format( Messages.getString("patient.error.badCharacterInPatientId.title"), // $NON-NLS-1$ illegalText), MessageFormat.format( Messages.getString("patient.error.badCharacterInPatientId"), // $NON-NLS-1$ iDartProperties.illegalPatientIdChars)); return false; } if (PatientManager.checkPatientIdentifier( getHSession(), newId.getPatient(), newId.getType(), newId.getValueEdit())) { showMessage( MessageDialog.ERROR, Messages.getString("PatientIdDialog.error.exists.title"), // $NON-NLS-1$ MessageFormat.format( Messages.getString("PatientIdDialog.error.exists.message"), // $NON-NLS-1$ newId.getType().getName(), newId.getValueEdit())); return false; } List<Patient> altPatients = PatientManager.getPatientsByAltId(getHSession(), newId.getType(), newId.getValueEdit()); if (!altPatients.isEmpty()) { String patientsWithThisOldId = EMPTY; for (Patient p : altPatients) { patientsWithThisOldId += (p.getPatientId() + ", "); // $NON-NLS-1$ } patientsWithThisOldId = patientsWithThisOldId.substring(0, patientsWithThisOldId.length() - 2); MessageBox mSave = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO); mSave.setText(Messages.getString("patient.warning.saveDuplicateId.title")); // $NON-NLS-1$ mSave.setMessage( MessageFormat.format( Messages.getString("patient.warning.saveDuplicateId"), // $NON-NLS-1$ patientsWithThisOldId)); if (mSave.open() != SWT.YES) { return false; } } } if (allEmpty) { showMessage( MessageDialog.ERROR, Messages.getString("PatientIdDialog.error.empty.title"), // $NON-NLS-1$ Messages.getString("PatientIdDialog.error.empyt.message")); // $NON-NLS-1$ return false; } return true; }
protected void cmdSaveSelected() { if (fieldsOk()) { Set<PatientIdentifier> patientIds = localPatient.getPatientIdentifiers(); for (PatientIdentifier newId : identiers) { if (newId.getValueEdit() == null || newId.getValueEdit().isEmpty()) { if (newId.getId() != -1) { patientIds.remove(newId); changesMade = true; } continue; } if (newId.getId() == -1) { changesMade = true; patientIds.add(newId); newId.setValue(newId.getValueEdit()); newId.setValueEdit(null); continue; } // check if an existing id was changed if (!newId.getValue().equals(newId.getValueEdit())) { changesMade = true; AlternatePatientIdentifier alt = new AlternatePatientIdentifier( newId.getValue(), localPatient, new Date(), true, newId.getType()); localPatient.getAlternateIdentifiers().add(alt); newId.setValue(newId.getValueEdit()); newId.setValueEdit(null); } } localPatient.setPatientId(localPatient.getPreferredIdentifier().getValue()); cmdCloseSelected(); } }