diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/ResultStoreStream.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/ResultStoreStream.java index 38daf2f3..d0ffc2f7 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/ResultStoreStream.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/ResultStoreStream.java @@ -45,8 +45,7 @@ public void appendResults(List entries) { writer.writeEntity(entries); } /** - * A more compact method to append data to the temp file without making assumptions about the composition. - * @param entries + * Appending data to the writer that supports multiple values per patient/variable combination */ public void appendMultiValueResults(List>> entries) { writer.writeMultiValueEntity(entries); diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/PfbResultStore.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/PfbResultStore.java deleted file mode 100644 index 57312006..00000000 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/PfbResultStore.java +++ /dev/null @@ -1,4 +0,0 @@ -package edu.harvard.hms.dbmi.avillach.hpds.processing.io; - -public class PfbResultStore { -} diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/PfbWriter.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/PfbWriter.java index 756336d7..93564c89 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/PfbWriter.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/PfbWriter.java @@ -94,6 +94,10 @@ private boolean isSingularField(String field) { return SINGULAR_FIELDS.contains(field); } + /** + * Transforms our variable names to once that are valid avro fields. We replace invalid characters with underscores + * and add a leading underscore if the variable starts with a number + */ protected String formatFieldName(String s) { String formattedFieldName = s.replaceAll("\\W", "_"); if (Character.isDigit(formattedFieldName.charAt(0))) { @@ -141,7 +145,11 @@ public void writeMultiValueEntity(Collection>> entities) { throw new IllegalArgumentException("Entity length much match the number of fields in this document"); } GenericRecord patientData = new GenericData.Record(patientDataSchema); + String patientId = ""; for(int i = 0; i < fields.size(); i++) { + if ("patient_id".equals(fields.get(i))) { + patientId = (entity.get(i) != null && !entity.get(i).isEmpty()) ? entity.get(i).get(0) : ""; + } if (isSingularField(fields.get(i))) { String entityValue = (entity.get(i) != null && !entity.get(i).isEmpty()) ? entity.get(i).get(0) : ""; patientData.put(fields.get(i), entityValue); @@ -155,7 +163,7 @@ public void writeMultiValueEntity(Collection>> entities) { GenericRecord entityRecord = new GenericData.Record(entitySchema); entityRecord.put("object", patientData); entityRecord.put("name", "patientData"); - entityRecord.put("id", "192035"); + entityRecord.put("id", patientId); try { dataFileWriter.append(entityRecord);