use of com.hartwig.hmftools.patientdb.data.PreTreatmentData 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.PreTreatmentData in project hmftools by hartwigmedical.
the class PatientReaderTest method canReadCpctPatientPreTherapy.
@Test
public void canReadCpctPatientPreTherapy() throws IOException {
final CpctEcrfModel model = loadTestEcrf();
assertEquals(1, model.patientCount());
final EcrfPatient cpctPatient = model.patients().iterator().next();
final PreTreatmentData preTreatmentData = new PreTreatmentReader(createTreatmentCurator()).read(cpctPatient);
assertEquals("Yes", preTreatmentData.treatmentGiven());
assertEquals("Yes", preTreatmentData.radiotherapyGiven());
final List<DrugData> drugs = preTreatmentData.drugs();
assertEquals(6, drugs.size());
}
use of com.hartwig.hmftools.patientdb.data.PreTreatmentData in project hmftools by hartwigmedical.
the class PreTreatmentReader method read.
@NotNull
PreTreatmentData read(@NotNull final EcrfPatient patient) throws IOException {
PreTreatmentData preTreatmentData = null;
for (final EcrfStudyEvent studyEvent : patient.studyEventsPerOID(STUDY_BASELINE)) {
for (final EcrfForm treatmentForm : studyEvent.nonEmptyFormsPerOID(FORM_TREATMENT, false)) {
String treatmentGiven = readTreatmentGiven(treatmentForm);
String radiotherapyGiven = readRadiotherapyGiven(treatmentForm);
final List<DrugData> drugs = readDrugs(treatmentForm);
if (preTreatmentData == null) {
preTreatmentData = ImmutablePreTreatmentData.of(treatmentGiven, radiotherapyGiven, drugs, treatmentForm.status(), treatmentForm.locked());
} else {
LOGGER.warn("Multiple pre-therapy forms for found patient: " + patient.patientId());
}
}
}
return preTreatmentData != null ? preTreatmentData : ImmutablePreTreatmentData.of(null, null, Lists.newArrayList(), FormStatusState.UNKNOWN, false);
}
use of com.hartwig.hmftools.patientdb.data.PreTreatmentData in project hmftools by hartwigmedical.
the class BaselineDataValidationTest method reportMissingPreTreatment.
@Test
public void reportMissingPreTreatment() {
PreTreatmentData emptyData = ImmutablePreTreatmentData.builder().formLocked(false).formStatus(FormStatusState.UNKNOWN).build();
assertEquals(2, PatientValidator.validatePreTreatmentData(PATIENT_IDENTIFIER, emptyData).size());
PreTreatmentData actualData = ImmutablePreTreatmentData.builder().radiotherapyGiven("Yes").treatmentGiven("No").formLocked(false).formStatus(FormStatusState.UNKNOWN).build();
assertEquals(0, PatientValidator.validatePreTreatmentData(PATIENT_IDENTIFIER, actualData).size());
PreTreatmentData onlyRadioTherapyPresent = ImmutablePreTreatmentData.builder().radiotherapyGiven("Yes").formLocked(false).formStatus(FormStatusState.UNKNOWN).build();
assertEquals(1, PatientValidator.validatePreTreatmentData(PATIENT_IDENTIFIER, onlyRadioTherapyPresent).size());
PreTreatmentData onlyTreatmentPresent = ImmutablePreTreatmentData.builder().treatmentGiven("Yes").formLocked(false).formStatus(FormStatusState.UNKNOWN).build();
assertEquals(1, PatientValidator.validatePreTreatmentData(PATIENT_IDENTIFIER, onlyTreatmentPresent).size());
}
Aggregations