WideEcrfFileReader { @NotNull public static List<WideResponseData> readResponses(@NotNull String pathToCsv) throws IOException { List<WideResponseData> wideResponses = Lists.newArrayList(); for (CSVRecord line : readCsvSkipHeader(pathToCsv, COMMA_DELIMITER)) { if (line.size() == RESPONSE_DATA_COUNT) { String widePatientId = WideFileInputInterpreter.toWideID(line.get(RESPONSE_DATA_PATIENT_ID)); if (!widePatientId.isEmpty()) { boolean recistDone = line.get(RESPONSE_DATA_RECIST_NOT_DONE).equals("FALSE"); ImmutableWideResponseData.Builder wideResponseBuilder = ImmutableWideResponseData.builder() .widePatientId(WideFileInputInterpreter.toWideID(line.get(RESPONSE_DATA_PATIENT_ID))) .timePoint(Integer.parseInt(line.get(RESPONSE_DATA_TIME_POINT))) .date(WideFileInputInterpreter.interpretDateEN(line.get(RESPONSE_DATA_DATE))) .recistDone(recistDone) .recistResponse(line.get(RESPONSE_DATA_RECIST_RESPONSE)); if (!recistDone) { wideResponseBuilder.noRecistResponse(line.get(RESPONSE_DATA_NO_RECIST_RESPONSE)) .noRecistReasonStopTreatment(line.get(RESPONSE_DATA_NO_RECIST_REASON_STOP_TREATMENT)) .noRecistReasonStopTreatmentOther(line.get(RESPONSE_DATA_NO_RECIST_REASON_STOP_TREATMENT_OTHER)); } wideResponses.add(wideResponseBuilder.build()); } } else { LOGGER.warn("Could not properly parse record in WIDE response csv: {}", line); } } return wideResponses; } private  WideEcrfFileReader(); @NotNull static List<WideFiveDays> readFiveDays(@NotNull String pathToCsv); @NotNull static List<WidePreAvlTreatmentData> readPreAvlTreatments(@NotNull String pathToCsv); @NotNull static List<WideBiopsyData> readBiopsies(@NotNull String pathToCsv); @NotNull static List<WideAvlTreatmentData> readAvlTreatments(@NotNull String pathToCsv); @NotNull static List<WideResponseData> readResponses(@NotNull String pathToCsv);  }
@Test public void canReadWideResponses() throws IOException { List<WideResponseData> responses = WideEcrfFileReader.readResponses(WIDE_TEST_DIR + File.separator + "wide_responses.csv"); assertEquals(3, responses.size()); assertEquals("WIDE01018888", responses.get(0).widePatientId()); assertEquals(1, responses.get(0).timePoint()); assertEquals(LocalDate.parse("2019-05-05"), responses.get(0).date()); assertFalse(responses.get(0).recistDone()); assertTrue(responses.get(0).recistResponse().isEmpty()); assertTrue(responses.get(0).noRecistResponse().isEmpty()); assertTrue(responses.get(0).noRecistReasonStopTreatment().isEmpty()); assertTrue(responses.get(0).noRecistReasonStopTreatmentOther().isEmpty()); assertEquals("WIDE01018888", responses.get(1).widePatientId()); assertEquals(2, responses.get(1).timePoint()); assertEquals(LocalDate.parse("2019-06-28"), responses.get(1).date()); assertFalse(responses.get(1).recistDone()); assertTrue(responses.get(1).recistResponse().isEmpty()); assertEquals("stop treatment", responses.get(1).noRecistResponse()); assertEquals("radiological progression of non-RECIST lesions", responses.get(1).noRecistReasonStopTreatment()); assertTrue(responses.get(1).noRecistReasonStopTreatmentOther().isEmpty()); assertEquals("WIDE01019999", responses.get(2).widePatientId()); assertEquals(1, responses.get(2).timePoint()); assertEquals(LocalDate.parse("2019-09-24"), responses.get(2).date()); assertTrue(responses.get(2).recistDone()); assertEquals("PD", responses.get(2).recistResponse()); assertNull(responses.get(2).noRecistResponse()); assertNull(responses.get(2).noRecistReasonStopTreatment()); assertNull(responses.get(2).noRecistReasonStopTreatmentOther()); }