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());
}
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());
}
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());
}
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());
}
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);
}
}
}
Aggregations