/** * @see PatientService#mergePatients(Patient,Patient) */ @Test public void mergePatients_shouldAuditVoidedRelationships() throws Exception { //create relationships and retrieve preferred and notPreferredPatient patient executeDataSet(PATIENT_RELATIONSHIPS_XML); Patient preferred = patientService.getPatient(999); Patient notPreferred = patientService.getPatient(2); voidOrders(Collections.singleton(notPreferred)); //merge the two patients and retrieve the audit object PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred); Assert.assertTrue( "relationship voiding not audited", isValueInList(personService.getRelationship(4).getUuid(), audit.getPersonMergeLogData().getVoidedRelationships())); }
/** * @see PatientService#mergePatients(Patient,Patient) */ @Test public void mergePatients_shouldAuditCreatedRelationships() throws Exception { //create relationships and retrieve preferred and notPreferredPatient patient executeDataSet(PATIENT_RELATIONSHIPS_XML); Patient preferred = patientService.getPatient(7); Patient notPreferred = patientService.getPatient(2); voidOrders(Collections.singleton(notPreferred)); //merge the two patients and retrieve the audit object PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred); //find the UUID of the created relationship as a result of the merge //note: since patient 2 is related to patient 1. patient 7 should now be related to patient 1 String createdRelationshipUuid = null; List<Relationship> relationships = personService.getRelationshipsByPerson(preferred); for (Relationship r : relationships) { if (r.getPersonB().getId().equals(1) || r.getPersonA().getId().equals(1)) { createdRelationshipUuid = r.getUuid(); } } Assert.assertNotNull("expected relationship was not found for the preferred patient after the merge", createdRelationshipUuid); Assert.assertTrue("relationship creation not audited", isValueInList(createdRelationshipUuid, audit.getPersonMergeLogData().getCreatedRelationships())); }