diff --git a/src/main/java/org/mitre/synthea/export/Exporter.java b/src/main/java/org/mitre/synthea/export/Exporter.java index ca3e9f8852..a0676bfaef 100644 --- a/src/main/java/org/mitre/synthea/export/Exporter.java +++ b/src/main/java/org/mitre/synthea/export/Exporter.java @@ -225,6 +225,8 @@ private static boolean exportRecord(Person person, String fileTag, long stopTime writeNewFile(outFilePath, bundleJson); } } + + if (Config.getAsBoolean("exporter.fhir.export")) { File outDirectory = getOutputFolder("fhir", person); if (Config.getAsBoolean("exporter.fhir.bulk_data")) { @@ -236,6 +238,17 @@ private static boolean exportRecord(Person person, String fileTag, long stopTime String entryJson = parser.encodeResourceToString(entry.getResource()); appendToFile(outFilePath, entryJson); } + // } else if (Config.getAsBoolean("exporter.fhir.longitudinal_data")) { + } else if (Config.getAsBoolean("exporter.fhir.personal_data")) { + org.hl7.fhir.r4.model.Bundle bundle = FhirR4.convertToFHIR(person, stopTime); + //IParser parser = FhirR4.getContext().newNdJsonParser().setPrettyPrint(false); + IParser parser = FhirR4.getContext().newJsonParser().setPrettyPrint(false); + for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent entry : bundle.getEntry()) { + String filename = entry.getResource().getResourceType().toString() + ".ndjson"; + Path outFilePath = outDirectory.toPath().resolve(filename); + String entryJson = parser.encodeResourceToString(entry.getResource()); + appendToFile(outFilePath, entryJson); + } } else { String bundleJson = FhirR4.convertToFHIRJson(person, stopTime); Path outFilePath = outDirectory.toPath().resolve(filename(person, fileTag, "json")); @@ -243,6 +256,10 @@ private static boolean exportRecord(Person person, String fileTag, long stopTime } FhirGroupExporterR4.addPatient((String) person.attributes.get(Person.ID)); } + + + + if (Config.getAsBoolean("exporter.ccda.export")) { String ccdaXml = CCDAExporter.export(person, stopTime); File outDirectory = getOutputFolder("ccda", person); @@ -255,6 +272,17 @@ private static boolean exportRecord(Person person, String fileTag, long stopTime Path outFilePath = outDirectory.toPath().resolve(filename(person, fileTag, "json")); writeNewFile(outFilePath, json); } + + if (Config.getAsBoolean("exporter.ndjson.export")) { + // NDJSON Export + // String ndJson = NdJsonExporter.export(person); + String json = JSONExporter.export(person); + File outDirectory = getOutputFolder("ndjson", person); + Path outFilePath = outDirectory.toPath().resolve(filename(person, fileTag, "ndjson")); + writeNewFile(outFilePath, json); + } + + if (Config.getAsBoolean("exporter.csv.export")) { try { CSVExporter.getInstance().export(person, stopTime); diff --git a/src/main/resources/synthea.properties b/src/main/resources/synthea.properties index 843845d50a..b8223f27da 100644 --- a/src/main/resources/synthea.properties +++ b/src/main/resources/synthea.properties @@ -22,6 +22,7 @@ exporter.fhir.us_core_version = 5.0.1 exporter.fhir.transaction_bundle = true # using bulk_data=true will ignore exporter.pretty_print exporter.fhir.bulk_data = false +exporter.fhir.personal_data = true # included_ and excluded_resources list out the resource types to include/exclude in the csv exporters. # only one of these may be set at a time, if both are set then both will be ignored. # if neither is set, then all resource types will be included. @@ -38,7 +39,9 @@ exporter.practitioner.fhir_dstu2.export = false exporter.encoding = UTF-8 exporter.json.export = false exporter.json.include_module_history = false +exporter.ndjson.export = false exporter.csv.export = false + # if exporter.csv.append_mode = true, then each run will add new data to any existing CSVs. if false, each run will clear out the files and start fresh exporter.csv.append_mode = false # if exporter.csv.folder_per_run = true, then each run will have CSVs placed into a unique subfolder. if false, each run will only use the top-level csv folder