From 3c23908e922534b5ce2b1ccca3782f84017b2a09 Mon Sep 17 00:00:00 2001 From: Dylan Hall Date: Thu, 17 Aug 2023 11:38:13 -0400 Subject: [PATCH] cleanup --- .../org/mitre/synthea/export/Exporter.java | 24 ++++++++++++------- .../mitre/synthea/export/PatientExporter.java | 7 +++--- .../export/PostCompletionExporter.java | 12 ++++++---- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/mitre/synthea/export/Exporter.java b/src/main/java/org/mitre/synthea/export/Exporter.java index b79d0ac3ea..c058a45e52 100644 --- a/src/main/java/org/mitre/synthea/export/Exporter.java +++ b/src/main/java/org/mitre/synthea/export/Exporter.java @@ -60,26 +60,32 @@ public enum SupportedFhirVersion { private static List patientExporters; private static List postCompletionExporters; - + + /** + * If the config setting "exporter.enable_custom_exporters" is enabled, + * load classes implementing the {@link PatientExporter} or {@link PostCompletionExporter} + * interfaces from the classpath, via the ServiceLoader. + */ public static void loadCustomExporters() { if (Config.getAsBoolean("exporter.enable_custom_exporters", false)) { - patientExporters = new LinkedList<>(); - postCompletionExporters = new LinkedList<>(); - + patientExporters = new ArrayList<>(); + postCompletionExporters = new ArrayList<>(); + ServiceLoader loader = ServiceLoader.load(PatientExporter.class); for (PatientExporter instance : loader) { System.out.println(instance.getClass().getCanonicalName()); patientExporters.add(instance); } - ServiceLoader loader2 = ServiceLoader.load(PostCompletionExporter.class); + ServiceLoader loader2 = + ServiceLoader.load(PostCompletionExporter.class); for (PostCompletionExporter instance : loader2) { System.out.println(instance.getClass().getCanonicalName()); postCompletionExporters.add(instance); } } } - + /** * Runtime configuration of the record exporter. */ @@ -341,13 +347,13 @@ private static boolean exportRecord(Person person, String fileTag, long stopTime String consolidatedNotes = ClinicalNoteExporter.export(person); writeNewFile(outFilePath, consolidatedNotes); } - + if (patientExporters != null && !patientExporters.isEmpty()) { for (PatientExporter patientExporter : patientExporters) { patientExporter.export(person, stopTime, options); } } - + if (options.isQueueEnabled()) { try { switch (options.queuedFhirVersion()) { @@ -538,7 +544,7 @@ public static void runPostCompletionExports(Generator generator, ExporterRuntime e.printStackTrace(); } } - + if (postCompletionExporters != null && !postCompletionExporters.isEmpty()) { for (PostCompletionExporter postCompletionExporter : postCompletionExporters) { postCompletionExporter.export(generator, options); diff --git a/src/main/java/org/mitre/synthea/export/PatientExporter.java b/src/main/java/org/mitre/synthea/export/PatientExporter.java index ae2f7bcf01..e5f3a800e9 100644 --- a/src/main/java/org/mitre/synthea/export/PatientExporter.java +++ b/src/main/java/org/mitre/synthea/export/PatientExporter.java @@ -4,13 +4,12 @@ import org.mitre.synthea.world.agents.Person; /** - * - * + * This interface defines an exporter that will be run for every patient + * in a simulation. */ public interface PatientExporter { - /** - * + * Export the given Person object. * @param person Patient to export * @param stopTime Time at which the simulation stopped * @param options Runtime exporter options diff --git a/src/main/java/org/mitre/synthea/export/PostCompletionExporter.java b/src/main/java/org/mitre/synthea/export/PostCompletionExporter.java index 192e711ccf..1871ca78ea 100644 --- a/src/main/java/org/mitre/synthea/export/PostCompletionExporter.java +++ b/src/main/java/org/mitre/synthea/export/PostCompletionExporter.java @@ -4,14 +4,16 @@ import org.mitre.synthea.export.Exporter.ExporterRuntimeOptions; /** - * - * + * This interface defines an exporter that will be invoked + * after the entire population has been generated. + * Example uses for this type of exporter include metadata, + * Payer- or Provider-based data, or working in combination with a separate + * PatientExporter where a final step is only performed once every patient + * has been handled. */ public interface PostCompletionExporter { /** - * - * @param generator - * @param options + * Export data based on the given Generator and options. */ void export(Generator generator, ExporterRuntimeOptions options); }