WideEcrfFileReader { @NotNull public static List<WideFiveDays> readFiveDays(@NotNull String pathToCsv) throws IOException { List<WideFiveDays> wideFiveDays = Lists.newArrayList(); for (CSVRecord line : readCsvSkipHeader(pathToCsv, COMMA_DELIMITER)) { if (line.size() == FIVE_DAYS_DATA_COUNT) { String widePatientId = WideFileInputInterpreter.toWideID(line.get(FIVE_DAYS_DATA_PATIENT_ID)); if (!widePatientId.isEmpty()) { boolean dataIsAvailable = line.get(FIVE_DAYS_DATA_IS_AVAILABLE).equals("1"); ImmutableWideFiveDays.Builder wideFiveDaysDataBuilder = ImmutableWideFiveDays.builder().widePatientId(widePatientId).dataIsAvailable(dataIsAvailable); if (dataIsAvailable) { wideFiveDaysDataBuilder.informedConsentDate(WideFileInputInterpreter.interpretDateIC(line.get( FIVE_DAYS_DATA_INFORMED_CONSENT_DATE))) .gender(WideFileInputInterpreter.convertGender(line.get(FIVE_DAYS_DATA_GENDER))) .birthYear(WideFileInputInterpreter.interpretBirthYear(line.get(FIVE_DAYS_DATA_BIRTH_YEAR))) .biopsyDate(WideFileInputInterpreter.interpretDateEN(line.get(FIVE_DAYS_DATA_BIOPSY_DATE))) .biopsySite(line.get(FIVE_DAYS_DATA_BIOPSY_SITE)) .sampleTissue(line.get(FIVE_DAYS_DATA_SAMPLE_TISSUE)) .sampleType(line.get(FIVE_DAYS_DATA_SAMPLE_TYPE)) .studyCode(line.get(FIVE_DAYS_DATA_STUDY_CODE)) .participatesInOtherTrials(WideFileInputInterpreter.convertParticipatesInOtherTrials(line.get( FIVE_DAYS_DATA_OTHER_TRIALS))) .otherTrialCodes(line.get(FIVE_DAYS_DATA_OTHER_TRIAL_CODES)) .otherTrialStartDates(line.get(FIVE_DAYS_DATA_OTHER_TRIAL_START_DATES)); } wideFiveDays.add(wideFiveDaysDataBuilder.build()); } } else { LOGGER.warn("Could not properly parse record in WIDE five days csv: {}", line); } } return wideFiveDays; } 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 canReadWideFiveDays() throws IOException { List<WideFiveDays> fiveDays = WideEcrfFileReader.readFiveDays(WIDE_TEST_DIR + File.separator + "wide_five_days.csv"); assertEquals(3, fiveDays.size()); assertEquals("WIDE01018888", fiveDays.get(0).widePatientId()); assertTrue(fiveDays.get(0).dataIsAvailable()); assertEquals(LocalDate.parse("2018-03-12"), fiveDays.get(0).informedConsentDate()); assertEquals("female", fiveDays.get(0).gender()); assertEquals(1940, (int) fiveDays.get(0).birthYear()); assertEquals(LocalDate.parse("2018-04-11"), fiveDays.get(0).biopsyDate()); assertEquals("peritoneum", fiveDays.get(0).biopsySite()); assertEquals("peritoneum", fiveDays.get(0).sampleTissue()); assertEquals("biopt", fiveDays.get(0).sampleType()); assertEquals("N18WGS-2", fiveDays.get(0).studyCode()); assertFalse(fiveDays.get(0).participatesInOtherTrials()); assertTrue(fiveDays.get(0).otherTrialCodes().isEmpty()); assertTrue(fiveDays.get(0).otherTrialStartDates().isEmpty()); assertEquals("WIDE01018888", fiveDays.get(1).widePatientId()); assertTrue(fiveDays.get(1).dataIsAvailable()); assertEquals(LocalDate.parse("2018-03-12"), fiveDays.get(1).informedConsentDate()); assertEquals("female", fiveDays.get(1).gender()); assertEquals(1940, (int) fiveDays.get(1).birthYear()); assertEquals(LocalDate.parse("2018-05-12"), fiveDays.get(1).biopsyDate()); assertEquals("lever", fiveDays.get(1).biopsySite()); assertEquals("lever neoplasie", fiveDays.get(1).sampleTissue()); assertEquals("biopt", fiveDays.get(1).sampleType()); assertEquals("N18WGS-2", fiveDays.get(1).studyCode()); assertFalse(fiveDays.get(1).participatesInOtherTrials()); assertTrue(fiveDays.get(1).otherTrialCodes().isEmpty()); assertTrue(fiveDays.get(1).otherTrialStartDates().isEmpty()); assertEquals("WIDE01019999", fiveDays.get(2).widePatientId()); assertFalse(fiveDays.get(2).dataIsAvailable()); assertNull(fiveDays.get(2).informedConsentDate()); assertNull(fiveDays.get(2).gender()); assertNull(fiveDays.get(2).birthYear()); assertNull(fiveDays.get(2).biopsyDate()); assertNull(fiveDays.get(2).biopsySite()); assertNull(fiveDays.get(2).sampleTissue()); assertNull(fiveDays.get(2).sampleType()); assertNull(fiveDays.get(2).studyCode()); assertNull(fiveDays.get(2).participatesInOtherTrials()); assertNull(fiveDays.get(2).otherTrialCodes()); assertNull(fiveDays.get(2).otherTrialStartDates()); }