Search in sources :

Example 1 with EcrfPatient

use of com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient 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);
}
Also used : Patient(com.hartwig.hmftools.patientdb.data.Patient) EcrfPatient(com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient) BaselineData(com.hartwig.hmftools.patientdb.data.BaselineData) BiopsyTreatmentData(com.hartwig.hmftools.patientdb.data.BiopsyTreatmentData) BiopsyTreatmentResponseData(com.hartwig.hmftools.patientdb.data.BiopsyTreatmentResponseData) ValidationFinding(com.hartwig.hmftools.common.ecrf.datamodel.ValidationFinding) TumorMarkerData(com.hartwig.hmftools.patientdb.data.TumorMarkerData) BiopsyData(com.hartwig.hmftools.patientdb.data.BiopsyData) PreTreatmentData(com.hartwig.hmftools.patientdb.data.PreTreatmentData) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with EcrfPatient

use of com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient in project hmftools by hartwigmedical.

the class BiopsyReaderTest method buildTestPatient.

@NotNull
private static EcrfPatient buildTestPatient() {
    final String patient = "dummy";
    EcrfItemGroup biopsy = new EcrfItemGroup(patient);
    biopsy.addItem(BiopsyReader.FIELD_BIOPSY_TAKEN, "Yes");
    biopsy.addItem(BiopsyReader.FIELD_BIOPSY_EVALUABLE, "Yes");
    // KODU: Create initial biopsy.
    EcrfItemGroup biopsies1 = new EcrfItemGroup(patient);
    biopsies1.addItem(BiopsyReader.FIELD_BIOPSY_DATE, "2017-11-10");
    biopsies1.addItem(BiopsyReader.FIELD_LOCATION, "liver");
    biopsies1.addItem(BiopsyReader.FIELD_SITE, "other");
    biopsies1.addItem(BiopsyReader.FIELD_SITE_OTHER, "body");
    EcrfForm form1 = new EcrfForm(patient, FormStatusState.SAVED, true);
    form1.addItemGroup(BiopsyReader.ITEMGROUP_BIOPSY, biopsy);
    form1.addItemGroup(BiopsyReader.ITEMGROUP_BIOPSIES, biopsies1);
    // KODU: Create empty 2nd biopsy
    EcrfItemGroup biopsies2 = new EcrfItemGroup(patient);
    EcrfForm form2 = new EcrfForm(patient, FormStatusState.SAVED, true);
    form2.addItemGroup(BiopsyReader.ITEMGROUP_BIOPSY, biopsy);
    form2.addItemGroup(BiopsyReader.ITEMGROUP_BIOPSIES, biopsies2);
    // KODU: Create duplicate 3rd biopsy
    EcrfItemGroup biopsies3 = new EcrfItemGroup(patient);
    biopsies3.addItem(BiopsyReader.FIELD_BIOPSY_DATE, "2017-11-10");
    biopsies3.addItem(BiopsyReader.FIELD_LOCATION, "liver");
    biopsies3.addItem(BiopsyReader.FIELD_SITE, "other");
    biopsies3.addItem(BiopsyReader.FIELD_SITE_OTHER, "body");
    EcrfForm form3 = new EcrfForm(patient, FormStatusState.SAVED, true);
    form3.addItemGroup(BiopsyReader.ITEMGROUP_BIOPSY, biopsy);
    form3.addItemGroup(BiopsyReader.ITEMGROUP_BIOPSIES, biopsies3);
    EcrfStudyEvent studyEvent = new EcrfStudyEvent(patient);
    studyEvent.addForm(BiopsyReader.FORM_BIOPS, form1);
    studyEvent.addForm(BiopsyReader.FORM_BIOPS, form2);
    studyEvent.addForm(BiopsyReader.FORM_BIOPS, form3);
    Map<String, List<EcrfStudyEvent>> studyEvents = Maps.newHashMap();
    studyEvents.put(BiopsyReader.STUDY_BIOPSY, Lists.newArrayList(studyEvent));
    return new EcrfPatient(patient, studyEvents, Lists.newArrayList());
}
Also used : EcrfStudyEvent(com.hartwig.hmftools.common.ecrf.datamodel.EcrfStudyEvent) EcrfItemGroup(com.hartwig.hmftools.common.ecrf.datamodel.EcrfItemGroup) EcrfForm(com.hartwig.hmftools.common.ecrf.datamodel.EcrfForm) List(java.util.List) EcrfPatient(com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient) Assert.assertNotNull(org.junit.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with EcrfPatient

use of com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient in project hmftools by hartwigmedical.

the class PatientReaderTest method canReadCpctPatientTreatmentResponses.

@Test
public void canReadCpctPatientTreatmentResponses() {
    final CpctEcrfModel model = loadTestEcrf();
    assertEquals(1, model.patientCount());
    final EcrfPatient cpctPatient = model.patients().iterator().next();
    final List<BiopsyTreatmentResponseData> treatmentResponses = BiopsyTreatmentResponseReader.read(cpctPatient);
    assertEquals(4, treatmentResponses.size());
    assertEquals(LocalDate.parse("2012-02-09", DATE_FORMATTER), treatmentResponses.get(0).date());
    assertEquals(null, treatmentResponses.get(0).response());
    assertEquals(null, treatmentResponses.get(0).measurementDone());
    assertEquals(LocalDate.parse("2012-03-05", DATE_FORMATTER), treatmentResponses.get(1).date());
    assertEquals("PD", treatmentResponses.get(1).response());
    assertEquals(null, treatmentResponses.get(1).measurementDone());
    assertEquals(LocalDate.parse("2012-04-23", DATE_FORMATTER), treatmentResponses.get(2).date());
    assertEquals("SD", treatmentResponses.get(2).response());
    assertEquals(null, treatmentResponses.get(2).measurementDone());
    assertEquals(LocalDate.parse("2012-06-08", DATE_FORMATTER), treatmentResponses.get(3).date());
    assertEquals("PR", treatmentResponses.get(3).response());
    assertEquals("Yes", treatmentResponses.get(3).measurementDone());
}
Also used : BiopsyTreatmentResponseData(com.hartwig.hmftools.patientdb.data.BiopsyTreatmentResponseData) EcrfPatient(com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient) CpctEcrfModel(com.hartwig.hmftools.common.ecrf.CpctEcrfModel) Test(org.junit.Test)

Example 4 with EcrfPatient

use of com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient 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());
}
Also used : DrugData(com.hartwig.hmftools.patientdb.data.DrugData) EcrfPatient(com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient) PreTreatmentData(com.hartwig.hmftools.patientdb.data.PreTreatmentData) CpctEcrfModel(com.hartwig.hmftools.common.ecrf.CpctEcrfModel) Test(org.junit.Test)

Example 5 with EcrfPatient

use of com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient in project hmftools by hartwigmedical.

the class PatientReaderTest method canReadCpctPatientTreatments.

@Test
public void canReadCpctPatientTreatments() throws IOException {
    final CpctEcrfModel model = loadTestEcrf();
    assertEquals(1, model.patientCount());
    final EcrfPatient cpctPatient = model.patients().iterator().next();
    final List<BiopsyTreatmentData> treatments = new BiopsyTreatmentReader(createTreatmentCurator()).read(cpctPatient);
    assertEquals(1, treatments.size());
    assertEquals(1, treatments.get(0).drugs().size());
    final LocalDate startDate = LocalDate.parse("2012-02-18", DATE_FORMATTER);
    final LocalDate endDate = LocalDate.parse("2012-04-02", DATE_FORMATTER);
    assertEquals("Bevacizumab", treatments.get(0).drugs().get(0).name());
    assertEquals(startDate, treatments.get(0).drugs().get(0).startDate());
    assertEquals(endDate, treatments.get(0).drugs().get(0).endDate());
    assertEquals(startDate, treatments.get(0).startDate());
    assertEquals(endDate, treatments.get(0).endDate());
    assertEquals("Bevacizumab", treatments.get(0).treatmentName());
    assertEquals("Yes", treatments.get(0).treatmentGiven());
}
Also used : EcrfPatient(com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient) BiopsyTreatmentData(com.hartwig.hmftools.patientdb.data.BiopsyTreatmentData) LocalDate(java.time.LocalDate) CpctEcrfModel(com.hartwig.hmftools.common.ecrf.CpctEcrfModel) Test(org.junit.Test)

Aggregations

EcrfPatient (com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient)15 Test (org.junit.Test)8 NotNull (org.jetbrains.annotations.NotNull)7 CpctEcrfModel (com.hartwig.hmftools.common.ecrf.CpctEcrfModel)6 EcrfForm (com.hartwig.hmftools.common.ecrf.datamodel.EcrfForm)3 EcrfItemGroup (com.hartwig.hmftools.common.ecrf.datamodel.EcrfItemGroup)3 EcrfStudyEvent (com.hartwig.hmftools.common.ecrf.datamodel.EcrfStudyEvent)3 FileInputStream (java.io.FileInputStream)3 List (java.util.List)3 XMLInputFactory (javax.xml.stream.XMLInputFactory)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 ImmutableFormStatusModel (com.hartwig.hmftools.common.ecrf.formstatus.ImmutableFormStatusModel)2 BaselineData (com.hartwig.hmftools.patientdb.data.BaselineData)2 BiopsyData (com.hartwig.hmftools.patientdb.data.BiopsyData)2 BiopsyTreatmentData (com.hartwig.hmftools.patientdb.data.BiopsyTreatmentData)2 BiopsyTreatmentResponseData (com.hartwig.hmftools.patientdb.data.BiopsyTreatmentResponseData)2 Patient (com.hartwig.hmftools.patientdb.data.Patient)2 PreTreatmentData (com.hartwig.hmftools.patientdb.data.PreTreatmentData)2 TumorMarkerData (com.hartwig.hmftools.patientdb.data.TumorMarkerData)2 Assert.assertNotNull (org.junit.Assert.assertNotNull)2