diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_jpa_empi/empi_operations.md b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_jpa_empi/empi_operations.md
index 1e3068f0d5f..94e9045fbe9 100644
--- a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_jpa_empi/empi_operations.md
+++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_jpa_empi/empi_operations.md
@@ -447,3 +447,70 @@ This might result in a response such as the following:
]
}
```
+
+## Clearing EMPI Links
+
+The `$empi-clear` operation is used to batch-delete EMPI links and related persons from the database. This operation is meant to
+be used during the rules-tuning phase of the EMPI implementation so that you can quickly test your ruleset.
+It permits the user to essentially "start fresh" without too much fuss.
+
+After the operation is complete, all targeted EMPI links will be removed from the system, and the Person resources which were involves in those links will be deleted and expunged
+from the server.
+
+This operation takes a single optional Parameter.
+
+
+
+
+ Name |
+ Type |
+ Cardinality |
+ Description |
+
+
+
+
+ resourceType |
+ String |
+ 0..1 |
+
+ The target Resource type you would like to clear. Currently limited to Patient/Practitioner. If omitted, will operate over all links.
+ |
+
+
+
+
+### Example
+
+Use an HTTP POST to the following URL to invoke this operation:
+
+```url
+http://example.com/$empi-clear
+```
+
+The following request body could be used:
+
+```json
+{
+ "resourceType": "Parameters",
+ "parameter": [ {
+ "name": "resourceType",
+ "valueString": "Patient"
+ } ]
+}
+```
+
+This operation returns the number of EMPI links that were cleared. The following is a sample response:
+
+```json
+{
+ "resourceType": "Parameters",
+ "parameter": [ {
+ "name": "reset",
+ "valueDecimal": 5
+ } ]
+}
+```
+
+
+
diff --git a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderClearLinkR4Test.java b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderClearLinkR4Test.java
index 7eba048441b..9a7ae65b0ea 100644
--- a/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderClearLinkR4Test.java
+++ b/hapi-fhir-jpaserver-empi/src/test/java/ca/uhn/fhir/jpa/empi/provider/EmpiProviderClearLinkR4Test.java
@@ -6,6 +6,7 @@ import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
+import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Person;
import org.hl7.fhir.r4.model.Practitioner;
@@ -120,8 +121,7 @@ public class EmpiProviderClearLinkR4Test extends BaseLinkR4Test {
linkPersons(personFromTarget2, personFromTarget);
//SUT
- myEmpiProviderR4.clearEmpiLinks(null);
-
+ Parameters parameters = myEmpiProviderR4.clearEmpiLinks(null);
assertNoPatientLinksExist();
IBundleProvider search = myPersonDao.search(new SearchParameterMap().setLoadSynchronous(true));
assertThat(search.size(), is(equalTo(0)));