Skip to content

Commit

Permalink
#1 XDS registry conformance Tests
Browse files Browse the repository at this point in the history
* Sent profile updates in a transaction bundle
  • Loading branch information
Thopap committed Nov 8, 2023
1 parent fe98934 commit cd80515
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.util.BundleBuilder;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBus;
Expand Down Expand Up @@ -69,14 +69,16 @@ public CustomMappings customMapping() {
@Bean
public SmartInitializingSingleton createProfilesIfNeeded(IGenericClient fhirClient) {
return () -> {
var builder = new BundleBuilder(fhirClient.getFhirContext());
var fhirParser = fhirClient.getFhirContext().newJsonParser();
for (var profile : profiles) {
try (InputStream inputStream = profile.getInputStream()) {
var mhdProfile = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
fhirClient.update().resource(mhdProfile).execute();
builder.addTransactionUpdateEntry(fhirParser.parseResource(inputStream));
} catch (IOException e) {
throw new IllegalStateException("MHD Profile definition shall be present");
}
}
fhirClient.transaction().withBundle(builder.getBundle()).execute();
};
}
}

0 comments on commit cd80515

Please sign in to comment.