better handle big files in mimic conversion

This commit is contained in:
Grahame Grieve 2019-11-10 21:03:00 +11:00
parent 7a9bdd0cfc
commit bed5e78234
1 changed files with 9 additions and 1 deletions

View File

@ -803,6 +803,7 @@ public class Mimic14Importer {
bnd.setType(BundleType.COLLECTION);
csv.readHeaders();
int t = 0;
int fc = 1;
while (csv.line()) {
t++;
Patient pat = patients.get(csv.cell("subject_id"));
@ -848,11 +849,18 @@ public class Mimic14Importer {
obs.addPerformer().setReference("PractitionerRole/"+prr.getId());
bnd.addEntry().setResource(obs);
if (bnd.getEntry().size() > 100000) {
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.changeFileExt(dest, ""+Integer.toString(fc)+".json")), bnd);
fc++;
bnd = new Bundle();
bnd.setId("chart-events");
bnd.setType(BundleType.COLLECTION);
}
}
}
System.out.println(Integer.toString(t)+" found");
csv.close();
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(dest), bnd);
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.changeFileExt(dest, ""+Integer.toString(fc)+".json")), bnd);
}
private Coding loincCoding(String loinc) {