Search in sources :

Example 1 with CpctEcrfModel

use of com.hartwig.hmftools.common.ecrf.CpctEcrfModel 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 2 with CpctEcrfModel

use of com.hartwig.hmftools.common.ecrf.CpctEcrfModel 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 3 with CpctEcrfModel

use of com.hartwig.hmftools.common.ecrf.CpctEcrfModel 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)

Example 4 with CpctEcrfModel

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

the class PatientReaderTest method canReadCpctPatientBiopsies.

@Test
public void canReadCpctPatientBiopsies() {
    final CpctEcrfModel model = loadTestEcrf();
    assertEquals(1, model.patientCount());
    final EcrfPatient cpctPatient = model.patients().iterator().next();
    final List<BiopsyData> biopsies = BiopsyReader.read(cpctPatient);
    assertEquals(1, biopsies.size());
    assertEquals("Soft tissue", biopsies.get(0).site());
    assertEquals("near right scapula", biopsies.get(0).location());
    assertEquals(LocalDate.parse("2012-02-17", DATE_FORMATTER), biopsies.get(0).date());
}
Also used : EcrfPatient(com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient) BiopsyData(com.hartwig.hmftools.patientdb.data.BiopsyData) CpctEcrfModel(com.hartwig.hmftools.common.ecrf.CpctEcrfModel) Test(org.junit.Test)

Example 5 with CpctEcrfModel

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

the class LoadDrupEcrfData method main.

public static void main(@NotNull final String[] args) throws ParseException, IOException, XMLStreamException, SQLException {
    final Options options = createOptions();
    final CommandLine cmd = createCommandLine(args, options);
    final String userName = cmd.getOptionValue(DB_USER);
    final String password = cmd.getOptionValue(DB_PASS);
    final String databaseUrl = cmd.getOptionValue(DB_URL);
    final String ecrfFile = cmd.getOptionValue(ECRF_FILE);
    final String runsFolderPath = cmd.getOptionValue(RUNS_DIR);
    if (Utils.anyNull(userName, password, databaseUrl, ecrfFile, runsFolderPath)) {
        final HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("patient-db - load DRUP ecrf", options);
    } else {
        final File runsDirectory = new File(runsFolderPath);
        if (runsDirectory.isDirectory()) {
            final String jdbcUrl = "jdbc:" + databaseUrl;
            final DatabaseAccess dbWriter = new DatabaseAccess(userName, password, jdbcUrl);
            dbWriter.clearDrupEcrf();
            LOGGER.info("Importing DRUP ecrf data from: {}", ecrfFile);
            final CpctEcrfModel model = CpctEcrfModel.loadFromXML(ecrfFile, new ImmutableFormStatusModel(Maps.newHashMap()));
            final List<RunContext> runContexts = RunsFolderReader.getRunContexts(runsDirectory);
            final Set<String> sequencedPatients = Utils.sequencedPatientIds(runContexts);
            LOGGER.info("Writing raw ecrf data for " + model.patientCount() + " patients.");
            dbWriter.writeDrupEcrf(model, sequencedPatients);
            LOGGER.info("Done writing raw ecrf data for " + model.patientCount() + " patients!");
        } else {
            if (!runsDirectory.exists()) {
                LOGGER.warn("dir " + runsDirectory + " does not exist.");
            }
            final HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("patient-db - load DRUP ecrf", options);
        }
    }
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) DatabaseAccess(com.hartwig.hmftools.patientdb.dao.DatabaseAccess) RunContext(com.hartwig.hmftools.common.context.RunContext) File(java.io.File) ImmutableFormStatusModel(com.hartwig.hmftools.common.ecrf.formstatus.ImmutableFormStatusModel) CpctEcrfModel(com.hartwig.hmftools.common.ecrf.CpctEcrfModel)

Aggregations

CpctEcrfModel (com.hartwig.hmftools.common.ecrf.CpctEcrfModel)9 EcrfPatient (com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient)7 Test (org.junit.Test)6 HelpFormatter (org.apache.commons.cli.HelpFormatter)3 FormStatusModel (com.hartwig.hmftools.common.ecrf.formstatus.FormStatusModel)2 RunContext (com.hartwig.hmftools.common.context.RunContext)1 ValidationFinding (com.hartwig.hmftools.common.ecrf.datamodel.ValidationFinding)1 ImmutableFormStatusModel (com.hartwig.hmftools.common.ecrf.formstatus.ImmutableFormStatusModel)1 Lims (com.hartwig.hmftools.common.lims.Lims)1 TreatmentCurator (com.hartwig.hmftools.patientdb.curators.TreatmentCurator)1 TumorLocationCurator (com.hartwig.hmftools.patientdb.curators.TumorLocationCurator)1 DatabaseAccess (com.hartwig.hmftools.patientdb.dao.DatabaseAccess)1 BaselineData (com.hartwig.hmftools.patientdb.data.BaselineData)1 BiopsyData (com.hartwig.hmftools.patientdb.data.BiopsyData)1 BiopsyTreatmentData (com.hartwig.hmftools.patientdb.data.BiopsyTreatmentData)1 BiopsyTreatmentResponseData (com.hartwig.hmftools.patientdb.data.BiopsyTreatmentResponseData)1 DrugData (com.hartwig.hmftools.patientdb.data.DrugData)1 Patient (com.hartwig.hmftools.patientdb.data.Patient)1 PreTreatmentData (com.hartwig.hmftools.patientdb.data.PreTreatmentData)1 TumorMarkerData (com.hartwig.hmftools.patientdb.data.TumorMarkerData)1