Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit 6cca376

Browse files
committed
Added GECKO FHIR Server connection test
1 parent c74146f commit 6cca376

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

  • codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/HapiFhirClientFactory.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
import org.hl7.fhir.instance.model.api.IBaseBundle;
66
import org.hl7.fhir.instance.model.api.IBaseResource;
7+
import org.hl7.fhir.r4.model.CapabilityStatement;
78
import org.slf4j.Logger;
89
import org.slf4j.LoggerFactory;
10+
import org.springframework.context.event.ContextRefreshedEvent;
11+
import org.springframework.context.event.EventListener;
912

1013
import ca.uhn.fhir.context.FhirContext;
1114
import ca.uhn.fhir.interceptor.api.IInterceptorService;
@@ -99,6 +102,33 @@ public HapiFhirClientFactory(FhirContext fhirContext, String serverBase, String
99102
clientFactory = null;
100103
}
101104

105+
@EventListener({ ContextRefreshedEvent.class })
106+
public void onContextRefreshedEvent(ContextRefreshedEvent event)
107+
{
108+
if (isConfigured())
109+
{
110+
try
111+
{
112+
logger.info(
113+
"Testing connection to GECCO FHIR server with {basicAuthUsername: {}, basicAuthPassword: {}, bearerToken: {}, serverBase: {}}",
114+
basicAuthUsername, basicAuthPassword != null ? "***" : "null",
115+
bearerToken != null ? "***" : "null", serverBase);
116+
117+
CapabilityStatement statement = getFhirStoreClient().capabilities().ofType(CapabilityStatement.class)
118+
.execute();
119+
120+
logger.info("Connection test OK {} - {}", statement.getSoftware().getName(),
121+
statement.getSoftware().getVersion());
122+
}
123+
catch (Exception e)
124+
{
125+
logger.error("Error while testing connection to GECCO FHIR server", e);
126+
}
127+
}
128+
else
129+
logger.warn("GECCO FHIR server Client stub implementation, no connection test performed");
130+
}
131+
102132
protected boolean isConfigured()
103133
{
104134
return serverBase != null && !serverBase.isEmpty();

0 commit comments

Comments
 (0)