Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async request pattern implementation #51

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>de.medizininformatik-initiative</groupId>
<artifactId>mii-process-report</artifactId>
<version>1.1.3.0-SNAPSHOT</version>
<version>1.2.0.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -45,7 +45,7 @@
<dependency>
<groupId>de.medizininformatik-initiative</groupId>
<artifactId>mii-processes-common</artifactId>
<version>1.0.3.0</version>
<version>1.1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class ReportProcessPluginDefinition implements ProcessPluginDefinition
{
public static final String VERSION = "1.1.3.0";
public static final String VERSION = "1.2.0.0";
public static final LocalDate RELEASE_DATE = LocalDate.of(2024, 11, 10);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ public class CreateReport extends AbstractServiceDelegate implements Initializin

private final String resourceVersion;
private final FhirClientFactory fhirClientFactory;
private final boolean fhirAsyncRequestsEnabled;
private final DataLogger dataLogger;

public CreateReport(ProcessPluginApi api, String resourceVersion, FhirClientFactory fhirClientFactory,
DataLogger dataLogger)
boolean fhirAsyncRequestsEnabled, DataLogger dataLogger)
{
super(api);

this.resourceVersion = resourceVersion;
this.fhirClientFactory = fhirClientFactory;
this.fhirAsyncRequestsEnabled = fhirAsyncRequestsEnabled;
this.dataLogger = dataLogger;
}

Expand Down Expand Up @@ -94,8 +96,8 @@ protected void doExecute(DelegateExecution execution, Variables variables)
private Bundle executeSearchBundle(Bundle searchBundle, String hrpIdentifier)
{
logger.info(
"Executing search Bundle from HRP '{}' against FHIR store with base url '{}' - this could take a while...",
hrpIdentifier, fhirClientFactory.getFhirClient().getFhirBaseUrl());
"Executing search Bundle from HRP '{}' against FHIR store with base URL '{}' - this could take a while...",
hrpIdentifier, fhirClientFactory.getFhirBaseUrl());

Bundle responseBundle = new Bundle();
responseBundle.setType(Bundle.BundleType.BATCHRESPONSE);
Expand All @@ -115,9 +117,10 @@ private Bundle.BundleEntryComponent executeRequest(String url)

try
{
logger.debug("Executing report search request '{}'", url);
logger.debug("Executing report search request '{}' with {}", url,
fhirAsyncRequestsEnabled ? "asnyc request pattern" : "normal request pattern");
Resource result = doExecuteRequest(url);

Resource result = fhirClientFactory.getFhirClient().search(url);
entry.setResource(result);
entry.setResponse(new Bundle.BundleEntryResponseComponent().setStatus(RESPONSE_OK));
}
Expand All @@ -137,6 +140,14 @@ private Bundle.BundleEntryComponent executeRequest(String url)
return entry;
}

private Resource doExecuteRequest(String url)
{
if (fhirAsyncRequestsEnabled)
return fhirClientFactory.getAsyncFhirClient().search(url);
else
return fhirClientFactory.getStandardFhirClient().search(url);
}

private Bundle transformToReportBundle(Bundle searchBundle, Bundle responseBundle, Target target)
{
Bundle report = new Bundle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public class FhirClientConfig
@Value("${de.medizininformatik.initiative.report.dic.fhir.dataLoggingEnabled:false}")
private boolean fhirDataLoggingEnabled;

@ProcessDocumentation(processNames = {
"medizininformatik-initiativede_reportSend" }, description = "Initial Result polling interval in milliseconds for asynchronous request pattern when executing search bundle requests, the interval will be increased tenfold after every check if a result is not ready")
@Value("${de.medizininformatik.initiative.report.dic.fhir.server.async.polling.interval:100}")
private int fhirAsyncInitialPollingIntervalMilliseconds;

@Value("${dev.dsf.bpe.fhir.server.organization.identifier.value}")
private String localIdentifierValue;

Expand All @@ -175,7 +180,8 @@ public FhirClientFactory fhirClientFactory()
return new FhirClientFactory(trustStorePath, certificatePath, privateKeyPath, fhirStorePrivateKeyPassword,
fhirStoreConnectTimeout, fhirStoreSocketTimeout, fhirStoreConnectionRequestTimeout, fhirStoreBaseUrl,
fhirStoreUsername, fhirStorePassword, fhirStoreBearerToken, tokenProvider(), proxyUrl, proxyUsername,
proxyPassword, fhirStoreHapiClientVerbose, fhirContext, localIdentifierValue, dataLogger());
proxyPassword, fhirStoreHapiClientVerbose, fhirAsyncInitialPollingIntervalMilliseconds, fhirContext,
localIdentifierValue, dataLogger());
}

public TokenProvider tokenProvider()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public class ReportConfig
@Value("${de.medizininformatik.initiative.report.dic.hrp.identifier:#{null}}")
private String hrpIdentifier;

@ProcessDocumentation(processNames = {
"medizininformatik-initiativede_reportSend" }, description = "To enable asynchronous request pattern when executing search bundle requests set to `true`")
@Value("${de.medizininformatik.initiative.report.dic.fhir.server.async.enabled:false}")
private boolean fhirAsyncEnabled;

// all Processes

@Bean
Expand Down Expand Up @@ -110,7 +115,7 @@ public SearchQueryCheckService searchQueryCheckService()
public CreateReport createReport()
{
String resourceVersion = new ReportProcessPluginDefinition().getResourceVersion();
return new CreateReport(api, resourceVersion, fhirClientConfig.fhirClientFactory(),
return new CreateReport(api, resourceVersion, fhirClientConfig.fhirClientFactory(), fhirAsyncEnabled,
fhirClientConfig.dataLogger());
}

Expand Down
Loading