Add failing test showing issue with related persons

This commit is contained in:
Tadgh 2020-07-24 17:18:59 -07:00
parent 90e96c1fb4
commit 7e694ded3f
1 changed files with 20 additions and 0 deletions

View File

@ -4,8 +4,10 @@ import ca.uhn.fhir.jpa.entity.EmpiLink;
import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Person; import org.hl7.fhir.r4.model.Person;
import org.hl7.fhir.r4.model.Practitioner; import org.hl7.fhir.r4.model.Practitioner;
import org.hl7.fhir.r4.model.Reference;
import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.StringType;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -82,6 +84,24 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
assertNoPatientLinksExist(); assertNoPatientLinksExist();
} }
@Test
public void testPersonWithLinksToOtherPersonsCanBeDeleted() {
createPatientAndUpdateLinks(buildJanePatient());
Patient patientAndUpdateLinks1 = createPatientAndUpdateLinks(buildJanePatient());
Patient patientAndUpdateLinks = createPatientAndUpdateLinks(buildPaulPatient());
Person personFromTarget = getPersonFromTarget(patientAndUpdateLinks);
Person personFromTarget2 = getPersonFromTarget(patientAndUpdateLinks1);
Person.PersonLinkComponent plc = new Person.PersonLinkComponent();
plc.setAssurance(Person.IdentityAssuranceLevel.LEVEL2);
plc.setTarget(new Reference(personFromTarget2.getIdElement().toUnqualifiedVersionless()));
personFromTarget.getLink().add(plc);
myPersonDao.update(personFromTarget);
myEmpiProviderR4.clearEmpiLinks(null);
assertNoPatientLinksExist();
}
@Test @Test
public void testClearPractitionerLinks() { public void testClearPractitionerLinks() {
assertLinkCount(2); assertLinkCount(2);