Skip to content

Commit

Permalink
Merge pull request #1491 from trifork/fix/include-all-files
Browse files Browse the repository at this point in the history
Moved generation of file to _after_ the other ndjson files are genera…
  • Loading branch information
jawalonoski authored Jul 29, 2024
2 parents 27e32d4 + 6a94603 commit 2b05973
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions src/main/java/org/mitre/synthea/export/Exporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -503,34 +503,6 @@ public static void runPostCompletionExports(Generator generator) {
*/
public static void runPostCompletionExports(Generator generator, ExporterRuntimeOptions options) {

if (Config.getAsBoolean("exporter.fhir.bulk_data")) {
IParser parser = FhirR4.getContext().newJsonParser();
parser.setPrettyPrint(false);
Parameters parameters = new Parameters()
.addParameter("inputFormat","application/fhir+ndjson");
File outDirectory = getOutputFolder("fhir", null);

File[] files = outDirectory.listFiles(pathname -> pathname.getName().endsWith("ndjson"));

String configHostname = Config.get("exporter.fhir.bulk_data.parameter_hostname");
String hostname = Strings.isNullOrEmpty(configHostname)
? "http://localhost:8080/" : configHostname;

for (File file : files) {
parameters.addParameter(
new Parameters.ParametersParameterComponent().setName("input")
.addPart(new Parameters.ParametersParameterComponent()
.setName("type")
.setValue(new StringType(file.getName().split("\\.")[0])))
.addPart(new Parameters.ParametersParameterComponent()
.setName("url")
.setValue(new StringType(hostname + file.getName()))));
}
overwriteFile(outDirectory.toPath().resolve("parameters.json"),
parser.encodeResourceToString(parameters));
}


if (options.deferExports) {
ExporterRuntimeOptions nonDeferredOptions = new ExporterRuntimeOptions(options);
nonDeferredOptions.deferExports = false;
Expand Down Expand Up @@ -619,6 +591,33 @@ public static void runPostCompletionExports(Generator generator, ExporterRuntime
TransitionMetrics.exportMetrics();
}

if (Config.getAsBoolean("exporter.fhir.bulk_data")) {
IParser parser = FhirR4.getContext().newJsonParser();
parser.setPrettyPrint(false);
Parameters parameters = new Parameters()
.addParameter("inputFormat","application/fhir+ndjson");
File outDirectory = getOutputFolder("fhir", null);

File[] files = outDirectory.listFiles(pathname -> pathname.getName().endsWith("ndjson"));

String configHostname = Config.get("exporter.fhir.bulk_data.parameter_hostname");
String hostname = Strings.isNullOrEmpty(configHostname)
? "http://localhost:8000/" : configHostname;

for (File file : files) {
parameters.addParameter(
new Parameters.ParametersParameterComponent().setName("input")
.addPart(new Parameters.ParametersParameterComponent()
.setName("type")
.setValue(new StringType(file.getName().split("\\.")[0])))
.addPart(new Parameters.ParametersParameterComponent()
.setName("url")
.setValue(new StringType(hostname + file.getName()))));
}
overwriteFile(outDirectory.toPath().resolve("parameters.json"),
parser.encodeResourceToString(parameters));
}

if (postCompletionExporters != null && !postCompletionExporters.isEmpty()) {
for (PostCompletionExporter postCompletionExporter : postCompletionExporters) {
postCompletionExporter.export(generator, options);
Expand Down

0 comments on commit 2b05973

Please sign in to comment.