registered diff provider (#791)

* registered  provider

* spotless fix
This commit is contained in:
craig mcclendon
2025-03-13 09:34:28 -05:00
committed by GitHub
parent f4f0585778
commit 8e7cb0e0a1
2 changed files with 40 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ import ca.uhn.fhir.jpa.model.config.SubscriptionSettings;
import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc;
import ca.uhn.fhir.jpa.packages.PackageInstallationSpec;
import ca.uhn.fhir.jpa.provider.DaoRegistryResourceSupportedSvc;
import ca.uhn.fhir.jpa.provider.DiffProvider;
import ca.uhn.fhir.jpa.provider.IJpaSystemProvider;
import ca.uhn.fhir.jpa.provider.JpaCapabilityStatementProvider;
import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2;
@@ -289,7 +290,8 @@ public class StarterJpaConfig {
ThreadSafeResourceDeleterSvc theThreadSafeResourceDeleterSvc,
ApplicationContext appContext,
Optional<IpsOperationProvider> theIpsOperationProvider,
Optional<IImplementationGuideOperationProvider> implementationGuideOperationProvider) {
Optional<IImplementationGuideOperationProvider> implementationGuideOperationProvider,
DiffProvider diffProvider) {
RestfulServer fhirServer = new RestfulServer(fhirSystemDao.getContext());
List<String> supportedResourceTypes = appProperties.getSupported_resource_types();
@@ -458,6 +460,9 @@ public class StarterJpaConfig {
// Validation
repositoryValidatingInterceptor.ifPresent(fhirServer::registerInterceptor);
// Diff Provider
fhirServer.registerProvider(diffProvider);
// register custom interceptors
registerCustomInterceptors(fhirServer, appContext, appProperties.getCustomInterceptorClasses());

View File

@@ -325,6 +325,39 @@ class ExampleServerR4IT implements IServerSupport {
}
@Test
void testDiffOperationIsRegistered() {
String methodName = "testDiff";
ourLog.info("Entering " + methodName + "()...");
Patient pt = new Patient();
pt.setActive(true);
pt.getBirthDateElement().setValueAsString("2020-01-01");
pt.addIdentifier().setSystem("http://foo").setValue("12345");
pt.addName().setFamily(methodName);
IIdType id = ourClient.create().resource(pt).execute().getId();
//now update the patient
pt.setId(id);
pt.getBirthDateElement().setValueAsString("2025-01-01");
ourClient.update().resource(pt).execute();
//now try a diff
Parameters outParams = ourClient.operation().onInstance(id).named("$diff").withNoParameters(Parameters.class).execute();
ourLog.trace("Params->\n{}", ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outParams));
boolean foundDobChange = false;
//really, if we get a response at all, then the Diff worked, but we'll check the contents here anyway for good measure to see that our change is reflected
for(Parameters.ParametersParameterComponent ppc : outParams.getParameter() ) {
for(Parameters.ParametersParameterComponent ppc2 : ppc.getPart() ) {
if( "Patient.birthDate".equals(ppc2.getValue().toString()) ){
foundDobChange = true;
break;
}
}
}
assertTrue(foundDobChange);
}
@BeforeEach
void beforeEach() {
@@ -338,4 +371,5 @@ class ExampleServerR4IT implements IServerSupport {
// return activeSubscriptionCount() == 2; // 2 subscription based on mdm-rules.json
//});
}
}