public ims.core.vo.Patient savePatientAndmergeRequest(ims.core.vo.Patient patient, MergedPatientVo patientBeforeMerged, MergeRequestVo mergeRequest, ims.core.vo.Patient sourcePatient, PatientIdCollection sourceDUPIdentifiers) throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException { if(patientBeforeMerged != null) { if(!patientBeforeMerged.isValidated()) throw new CodingRuntimeException("MergedPatientVo is not validated."); DomainFactory factory = getDomainFactory(); MergedPatient doMergedPatient = MergedPatientVoAssembler.extractMergedPatient(factory, patientBeforeMerged); factory.save(doMergedPatient); } PatientMerge mergeImpl = (PatientMerge) getDomainImpl(PatientMergeImpl.class); mergeImpl.saveMergeRequest(mergeRequest); Demographics impl = (Demographics) getDomainImpl(DemographicsImpl.class); if(sourcePatient != null) { sourcePatient = impl.savePatient(sourcePatient, false); } ims.core.vo.Patient dest = impl.savePatient(patient, false); if(sourcePatient != null) { if(sourceDUPIdentifiers != null) { for(PatientId iden : sourceDUPIdentifiers) { if(sourcePatient.getIdentifiers() == null) sourcePatient.setIdentifiers(new PatientIdCollection()); sourcePatient.getIdentifiers().add(iden); } sourcePatient.validate(); impl.savePatient(sourcePatient, false); } } return dest; }