use of com.hartwig.hmftools.patientdb.data.BaselineData in project hmftools by hartwigmedical.
the class PatientReader method read.
@NotNull
public Patient read(@NotNull final EcrfPatient ecrfPatient, @NotNull final List<SampleData> sequencedSamples) throws IOException {
LOGGER.info("Reading patient " + ecrfPatient.patientId() + " with samples: " + sequencedSamples);
final BaselineData baselineData = cpctPatientReader.read(ecrfPatient);
final PreTreatmentData preTreatmentData = preTreatmentReader.read(ecrfPatient);
final List<BiopsyData> clinicalBiopsies = BiopsyReader.read(ecrfPatient);
final List<BiopsyTreatmentData> treatments = biopsyTreatmentReader.read(ecrfPatient);
final List<BiopsyTreatmentResponseData> treatmentResponses = BiopsyTreatmentResponseReader.read(ecrfPatient);
final List<TumorMarkerData> tumorMarkers = TumorMarkerReader.read(ecrfPatient);
final MatchResult<BiopsyData> matchedBiopsies = BiopsyMatcher.matchBiopsiesToTumorSamples(ecrfPatient.patientId(), sequencedSamples, clinicalBiopsies);
final MatchResult<BiopsyTreatmentData> matchedTreatments = TreatmentMatcher.matchTreatmentsToBiopsies(ecrfPatient.patientId(), clinicalBiopsies, treatments);
final MatchResult<BiopsyTreatmentResponseData> matchedResponses = TreatmentResponseMatcher.matchTreatmentResponsesToTreatments(ecrfPatient.patientId(), treatments, treatmentResponses);
final List<ValidationFinding> findings = Lists.newArrayList();
findings.addAll(matchedBiopsies.findings());
findings.addAll(matchedTreatments.findings());
findings.addAll(matchedResponses.findings());
return new Patient(ecrfPatient.patientId(), baselineData, preTreatmentData, sequencedSamples, matchedBiopsies.values(), matchedTreatments.values(), matchedResponses.values(), tumorMarkers, findings);
}
use of com.hartwig.hmftools.patientdb.data.BaselineData in project hmftools by hartwigmedical.
the class PatientValidator method validateInformedConsentDate.
@NotNull
static List<ValidationFinding> validateInformedConsentDate(@NotNull final String patientIdentifier, @NotNull final BaselineData baselineData, @NotNull final List<BiopsyData> biopsies) {
final List<ValidationFinding> findings = Lists.newArrayList();
final LocalDate informedConsentDate = baselineData.informedConsentDate();
if (informedConsentDate != null && !biopsies.isEmpty()) {
final List<BiopsyData> biopsiesPriorToInformedConsent = biopsies.stream().filter(biopsy -> {
final LocalDate biopsyDate = biopsy.date();
return biopsyDate != null && biopsyDate.isBefore(informedConsentDate);
}).collect(Collectors.toList());
if (biopsiesPriorToInformedConsent.size() > 0) {
final String detailsMessage = "informedConsentDate: " + informedConsentDate + ". biopsies: " + biopsiesPriorToInformedConsent.stream().map(BiopsyData::toString).collect(Collectors.toList());
FormStatusState best = baselineData.informedConsentStatus();
boolean locked = baselineData.informedConsentLocked();
for (BiopsyData biopsy : biopsies) {
best = FormStatusState.best(best, biopsy.formStatus());
locked = locked || biopsy.formLocked();
}
findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, fields(FIELD_INFORMED_CONSENT_DATE, FIELD_BIOPSY_DATE), "at least 1 biopsy taken before informed consent date", best, locked, detailsMessage));
}
}
return findings;
}
use of com.hartwig.hmftools.patientdb.data.BaselineData in project hmftools by hartwigmedical.
the class PatientReaderTest method canReadCpctPatientInfo.
@Test
public void canReadCpctPatientInfo() {
final CpctEcrfModel model = loadTestEcrf();
assertEquals(1, model.patientCount());
final EcrfPatient cpctPatient = model.patients().iterator().next();
final CpctPatientReader cpctPatientReader = new CpctPatientReader(model, createTumorLocationCurator());
final BaselineData baselineData = cpctPatientReader.read(cpctPatient);
assertEquals("Breast cancer", baselineData.cancerType().searchTerm());
assertEquals("Breast", baselineData.cancerType().category());
assertEquals("Breast Cancer: subtype unknown", baselineData.cancerType().subcategory());
assertEquals("female", baselineData.gender());
assertEquals("Bernhoven uden", baselineData.hospital());
assertEquals(new Integer(1963), baselineData.birthYear());
assertEquals(LocalDate.parse("2012-06-22", DATE_FORMATTER), baselineData.deathDate());
assertEquals(LocalDate.parse("2012-02-17", DATE_FORMATTER), baselineData.registrationDate());
assertEquals(LocalDate.parse("2012-02-17", DATE_FORMATTER), baselineData.informedConsentDate());
}
Aggregations