Skip to content

Commit

Permalink
fTTP BF fix, added support for lab values, reworked FHIR store clients
Browse files Browse the repository at this point in the history
fTTP BF resolution was missing the source/ prefix for the pseudonym.
Adds support for lab values with profile
https://www.medizininformatik-initiative.de/fhir/core/modul-labor/StructureDefinition/ObservationLab
Uses the loinc code in the update condition for lab values as discussed
in #4.
Adds an initial FHIR store implementation for the fhir-bridge.
  • Loading branch information
hhund committed Jun 13, 2021
1 parent f9766a8 commit bc9ceb5
Show file tree
Hide file tree
Showing 17 changed files with 1,176 additions and 519 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public interface ConstantsDataTransfer
String NAMING_SYSTEM_NUM_CODEX_CRR_PSEUDONYM = "http://www.netzwerk-universitaetsmedizin.de/sid/crr-pseudonym";
String NAMING_SYSTEM_NUM_CODEX_BLOOM_FILTER = "http://www.netzwerk-universitaetsmedizin.de/sid/bloom-filter";

String RFC_4122_SYSTEM = "urn:ietf:rfc:4122";

String CODESYSTEM_NUM_CODEX_DATA_TRANSFER = "http://www.netzwerk-universitaetsmedizin.de/fhir/CodeSystem/data-transfer";
String CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_PATIENT = "patient";
String CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_PSEUDONYM = "pseudonym";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import ca.uhn.fhir.context.FhirContext;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.fhir.FhirClient;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.fhir.FhirClientBuilder;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.domain.DateWithPrecision;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.variables.PatientReference;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.variables.PatientReferenceList;
Expand All @@ -39,19 +41,23 @@ public class FhirClientFactory
private final Path searchBundleOverride;
private final String localIdentifierValue;

private final FhirClientBuilder builder;

public FhirClientFactory(HapiFhirClientFactory hapiClientFactory, FhirContext fhirContext,
Path searchBundleOverride, String localIdentifierValue)
Path searchBundleOverride, String localIdentifierValue, FhirClientBuilder builder)
{
this.hapiClientFactory = hapiClientFactory;
this.fhirContext = fhirContext;
this.searchBundleOverride = searchBundleOverride;
this.localIdentifierValue = localIdentifierValue;

this.builder = builder;
}

public FhirClient getFhirClient()
{
if (hapiClientFactory.isConfigured())
return new FhirClientImpl(hapiClientFactory, fhirContext, searchBundleOverride);
return builder.build(fhirContext, hapiClientFactory, searchBundleOverride);
else
return createFhirClientStub();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public Optional<String> getDicPseudonym(String bloomFilter)
.withParameters(createParametersForBfWorkflow(bloomFilter)).accept(Constants.CT_FHIR_XML_NEW)
.encoded(EncodingEnum.XML).execute();

return getPseudonym(parameters);
return getPseudonym(parameters).map(p -> fttpTarget + "/" + p);
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class HapiFhirClientFactory
private final String basicAuthUsername;
private final String basicAuthPassword;
private final String bearerToken;
private final boolean supportsIdentifierReferenceSearch;

private final ApacheRestfulClientFactory clientFactory;

Expand All @@ -62,10 +61,9 @@ public class HapiFhirClientFactory
* may be <code>null</code>
* @param bearerToken
* may be <code>null</code>
* @param supportsIdentifierReferenceSearch
*/
public HapiFhirClientFactory(FhirContext fhirContext, String serverBase, String basicAuthUsername,
String basicAuthPassword, String bearerToken, boolean supportsIdentifierReferenceSearch)
String basicAuthPassword, String bearerToken)
{
if (fhirContext != null)
this.fhirContext = fhirContext;
Expand All @@ -76,7 +74,6 @@ public HapiFhirClientFactory(FhirContext fhirContext, String serverBase, String
this.basicAuthUsername = basicAuthUsername;
this.basicAuthPassword = basicAuthPassword;
this.bearerToken = bearerToken;
this.supportsIdentifierReferenceSearch = supportsIdentifierReferenceSearch;

if (isConfigured())
{
Expand All @@ -87,11 +84,6 @@ public HapiFhirClientFactory(FhirContext fhirContext, String serverBase, String
clientFactory = null;
}

public boolean supportsIdentifierReferenceSearch()
{
return supportsIdentifierReferenceSearch;
}

protected boolean isConfigured()
{
return serverBase != null && !serverBase.isEmpty();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client;

import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.hl7.fhir.r4.model.OperationOutcome;
import org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity;
import org.slf4j.Logger;

public class OutcomeLogger
{
private final Logger logger;

public OutcomeLogger(Logger logger)
{
this.logger = logger;
}

public void logOutcome(OperationOutcome outcome)
{
outcome.getIssue().forEach(issue ->
{
String display = issue.getCode() == null ? null : issue.getCode().getDisplay();
String details = issue.getDetails() == null ? null : issue.getDetails().getText();
String diagnostics = issue.getDiagnostics();

String message = Stream.of(display, details, diagnostics).filter(s -> s != null && !s.isBlank())
.collect(Collectors.joining(" "));

getLoggerForSeverity(issue.getSeverity(), logger).accept("Issue: {}", message);
});
}

private BiConsumer<String, Object> getLoggerForSeverity(IssueSeverity severity, Logger logger)
{
if (severity != null)
{
switch (severity)
{
case ERROR:
case FATAL:
return logger::error;
case WARNING:
return logger::warn;
case NULL:
case INFORMATION:
default:
return logger::info;
}
}

return logger::info;
}
}
Loading

0 comments on commit bc9ceb5

Please sign in to comment.