use of com.hartwig.hmftools.patientdb.data.DrugData 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.DrugData in project hmftools by hartwigmedical.
the class BiopsyTreatmentReader method readDrugs.
@NotNull
private List<DrugData> readDrugs(@NotNull final EcrfForm treatmentForm) throws IOException {
final List<DrugData> drugs = Lists.newArrayList();
for (final EcrfItemGroup itemGroup : treatmentForm.nonEmptyItemGroupsPerOID(ITEMGROUP_SYSPOSTBIO, false)) {
final LocalDate drugStart = itemGroup.readItemDate(FIELD_DRUG_START, 0, DATE_FORMATTER, false);
final LocalDate drugEnd = itemGroup.readItemDate(FIELD_DRUG_END, 0, DATE_FORMATTER, false);
String drugName = itemGroup.readItemString(FIELD_DRUG, 0, false);
if (drugName == null || drugName.trim().toLowerCase().startsWith("other")) {
drugName = itemGroup.readItemString(FIELD_DRUG_OTHER, 0, false);
}
final List<CuratedTreatment> curatedDrugs = drugName == null ? Lists.newArrayList() : treatmentCurator.search(drugName);
drugs.add(ImmutableDrugData.of(drugName, drugStart, drugEnd, null, curatedDrugs));
}
return drugs;
}
use of com.hartwig.hmftools.patientdb.data.DrugData 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.DrugData in project hmftools by hartwigmedical.
the class PreTreatmentReader method readDrugs.
@NotNull
private List<DrugData> readDrugs(@NotNull final EcrfForm treatmentForm) throws IOException {
final List<DrugData> drugs = Lists.newArrayList();
for (final EcrfItemGroup itemGroup : treatmentForm.nonEmptyItemGroupsPerOID(ITEMGROUP_DRUGS, false)) {
final LocalDate drugStart = itemGroup.readItemDate(FIELD_PRE_DRUG_START, 0, DATE_FORMATTER, false);
final LocalDate drugEnd = itemGroup.readItemDate(FIELD_PRE_DRUG_END, 0, DATE_FORMATTER, false);
final String drugName = itemGroup.readItemString(FIELD_PRE_DRUG, 0, false);
final String bestResponse = itemGroup.readItemString(FIELD_PRE_BEST_RESPONSE, 0, false);
final List<CuratedTreatment> curatedDrugs = drugName == null ? Lists.newArrayList() : treatmentCurator.search(drugName);
drugs.add(ImmutableDrugData.of(drugName, drugStart, drugEnd, bestResponse, curatedDrugs));
}
return drugs;
}
use of com.hartwig.hmftools.patientdb.data.DrugData in project hmftools by hartwigmedical.
the class BiopsyTreatmentReader method read.
@NotNull
List<BiopsyTreatmentData> read(@NotNull final EcrfPatient patient) throws IOException {
final List<BiopsyTreatmentData> treatments = Lists.newArrayList();
for (final EcrfStudyEvent studyEvent : patient.studyEventsPerOID(STUDY_AFTERBIOPT)) {
for (final EcrfForm treatmentForm : studyEvent.nonEmptyFormsPerOID(FORM_TREATMENT, false)) {
final String treatmentGiven = readTreatmentGiven(treatmentForm);
final String radiotherapyGiven = readRadiotherapyGiven(treatmentForm);
final List<DrugData> drugs = readDrugs(treatmentForm);
treatments.add(ImmutableBiopsyTreatmentData.of(treatmentGiven, radiotherapyGiven, drugs, treatmentForm.status(), treatmentForm.locked()));
}
}
return treatments;
}
Aggregations