WideEcrfFileReader { @NotNull public static List<WidePreAvlTreatmentData> readPreAvlTreatments(@NotNull String pathToCsv) throws IOException { List<WidePreAvlTreatmentData> widePreTreatments = Lists.newArrayList(); for (CSVRecord line : readCsvSkipHeader(pathToCsv, COMMA_DELIMITER)) { if (line.size() == PRE_AVL_TREATMENT_DATA_COUNT) { String widePatientId = WideFileInputInterpreter.toWideID(line.get(PRE_AVL_TREATMENT_DATA_PATIENT_ID)); if (!widePatientId.isEmpty()) { WidePreAvlTreatmentData widePreAvlTreatment = ImmutableWidePreAvlTreatmentData.builder() .widePatientId(widePatientId) .hasPreviousTherapy(line.get(PRE_AVL_TREATMENT_DATA_HAS_PREVIOUS_THERAPY).equals("1")) .drug1(line.get(PRE_AVL_TREATMENT_DATA_DRUG1)) .drug2(line.get(PRE_AVL_TREATMENT_DATA_DRUG2)) .drug3(line.get(PRE_AVL_TREATMENT_DATA_DRUG3)) .drug4(line.get(PRE_AVL_TREATMENT_DATA_DRUG4)) .lastSystemicTherapyDate(WideFileInputInterpreter.interpretDateEN(line.get( PRE_AVL_TREATMENT_DATA_LAST_SYSTEMIC_THERAPY_DATE))) .build(); widePreTreatments.add(widePreAvlTreatment); } } else { LOGGER.warn("Could not properly parse record in WIDE pre-AVL treatment csv: {}", line); } } return widePreTreatments; } 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 canReadWidePreAvlTreatments() throws IOException { List<WidePreAvlTreatmentData> preTreatments = WideEcrfFileReader.readPreAvlTreatments(WIDE_TEST_DIR + File.separator + "wide_pre_avl_treatments.csv"); assertEquals(3, preTreatments.size()); assertEquals("WIDE01018888", preTreatments.get(0).widePatientId()); assertFalse(preTreatments.get(0).hasPreviousTherapy()); assertTrue(preTreatments.get(0).drug1().isEmpty()); assertTrue(preTreatments.get(0).drug2().isEmpty()); assertTrue(preTreatments.get(0).drug3().isEmpty()); assertTrue(preTreatments.get(0).drug4().isEmpty()); assertNull(preTreatments.get(0).lastSystemicTherapyDate()); assertEquals("WIDE01019999", preTreatments.get(1).widePatientId()); assertTrue(preTreatments.get(1).hasPreviousTherapy()); assertEquals("erlotinib", preTreatments.get(1).drug1()); assertTrue(preTreatments.get(1).drug2().isEmpty()); assertTrue(preTreatments.get(1).drug3().isEmpty()); assertTrue(preTreatments.get(1).drug4().isEmpty()); assertEquals(LocalDate.parse("2018-12-17"), preTreatments.get(1).lastSystemicTherapyDate()); assertEquals("WIDE01019999", preTreatments.get(2).widePatientId()); assertTrue(preTreatments.get(2).hasPreviousTherapy()); assertEquals("carboplatin,others", preTreatments.get(2).drug1()); assertEquals("pemetrexed", preTreatments.get(2).drug2()); assertEquals("irinotecan", preTreatments.get(2).drug3()); assertEquals("bevacizumab", preTreatments.get(2).drug4()); assertEquals(LocalDate.parse("2018-12-17"), preTreatments.get(2).lastSystemicTherapyDate()); }