Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dehall authored and hadleynet committed Aug 22, 2023
1 parent c09ed32 commit 3c23908
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
24 changes: 15 additions & 9 deletions src/main/java/org/mitre/synthea/export/Exporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,32 @@ public enum SupportedFhirVersion {

private static List<PatientExporter> patientExporters;
private static List<PostCompletionExporter> 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<PatientExporter> loader = ServiceLoader.load(PatientExporter.class);
for (PatientExporter instance : loader) {
System.out.println(instance.getClass().getCanonicalName());
patientExporters.add(instance);
}

ServiceLoader<PostCompletionExporter> loader2 = ServiceLoader.load(PostCompletionExporter.class);
ServiceLoader<PostCompletionExporter> loader2 =
ServiceLoader.load(PostCompletionExporter.class);
for (PostCompletionExporter instance : loader2) {
System.out.println(instance.getClass().getCanonicalName());
postCompletionExporters.add(instance);
}
}
}

/**
* Runtime configuration of the record exporter.
*/
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/mitre/synthea/export/PatientExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 3c23908

Please sign in to comment.