private PrivatePatientLocal getPrivatePatient(
     PatientLocal patient, int type, boolean includeStudies)
     throws FinderException, CreateException {
   Collection col =
       privPatHome.findByPatientIdWithIssuer(
           type, patient.getPatientId(), patient.getIssuerOfPatientId());
   PrivatePatientLocal privPat;
   if (col.isEmpty()) {
     privPat = privPatHome.create(type, patient.getAttributes(true));
   } else {
     privPat = (PrivatePatientLocal) col.iterator().next();
   }
   if (includeStudies) {
     for (Iterator iter = patient.getStudies().iterator(); iter.hasNext(); ) {
       getPrivateStudy((StudyLocal) iter.next(), type, privPat, true); // move
       // also
       // all
       // instances
     }
   }
   return privPat;
 }
 /** @ejb.interface-method */
 public Collection movePatientToTrash(long pat_pk) throws RemoteException {
   try {
     PatientLocal patient = patHome.findByPrimaryKey(new Long(pat_pk));
     Collection col = patient.getStudies();
     Collection result = new ArrayList();
     for (Iterator iter = col.iterator(); iter.hasNext(); ) {
       result.add(getStudyMgtDataset((StudyLocal) iter.next(), null));
     }
     Dataset ds = patient.getAttributes(true);
     getPrivatePatient(patient, DELETED, true);
     patient.remove();
     if (result.isEmpty()) result.add(ds);
     return result;
   } catch (CreateException e) {
     throw new RemoteException(e.getMessage());
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (FinderException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
 /** @ejb.interface-method view-type="local" */
 public void updatePatientNameSoundex(PatientLocal pat) {
   PersonName pn = newPersonName(pat.getPatientName());
   pat.setPatientFamilyNameSoundex(AttributeFilter.toSoundex(pn, PersonName.FAMILY, "*"));
   pat.setPatientGivenNameSoundex(AttributeFilter.toSoundex(pn, PersonName.GIVEN, "*"));
 }