PatientValidator { @NotNull @VisibleForTesting static List<ValidationFinding> validateBaselineData(@NotNull String patientIdentifier, @NotNull BaselineData baselineData) { List<ValidationFinding> findings = Lists.newArrayList(); if (baselineData.curatedTumorLocation().searchTerm() == null) { findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, "Primary tumor location empty", baselineData.primaryTumorStatus())); } if (baselineData.gender() == null) { findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, "Gender empty", baselineData.demographyStatus())); } if (baselineData.registrationDate() == null) { findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, "Registration date empty or in wrong format", FormStatus.merge(baselineData.selectionCriteriaStatus(), baselineData.eligibilityStatus()))); } if (baselineData.informedConsentDate() == null) { findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, "Informed consent date empty or in wrong format", baselineData.informedConsentStatus())); } if (baselineData.birthYear() == null) { findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, "Birth year could not be determined", FormStatus.merge(baselineData.eligibilityStatus(), baselineData.selectionCriteriaStatus()))); } if (baselineData.hospital() == null) { findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, "Hospital could not be determined", FormStatus.merge(baselineData.eligibilityStatus(), baselineData.selectionCriteriaStatus()))); } return findings; }  @NotNull static List<ValidationFinding> validatePatient(@NotNull Patient patient);  }
@Test public void reportsMissingBaselineFields() { List<ValidationFinding> findings = PatientValidator.validateBaselineData(PATIENT_IDENTIFIER, EMPTY_BASELINE); assertEquals(6, findings.size()); findings.stream().map(ValidationFinding::patientIdentifier).forEach(id -> assertEquals(PATIENT_IDENTIFIER, id)); }