use of com.hartwig.hmftools.common.ecrf.datamodel.EcrfItemGroup 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());
}
use of com.hartwig.hmftools.common.ecrf.datamodel.EcrfItemGroup in project hmftools by hartwigmedical.
the class BiopsyReader method read.
@NotNull
static List<BiopsyData> read(@NotNull final EcrfPatient patient) {
final List<BiopsyData> biopsies = Lists.newArrayList();
for (final EcrfStudyEvent studyEvent : patient.studyEventsPerOID(STUDY_BIOPSY)) {
for (final EcrfForm form : studyEvent.nonEmptyFormsPerOID(FORM_BIOPS, false)) {
String biopsyTaken = null;
String biopsyEvaluable = null;
// KODU: This works as there is generally a 1:N relation between BIOPSY and BIOPSIES item groups.
for (final EcrfItemGroup biopsyGroup : form.nonEmptyItemGroupsPerOID(ITEMGROUP_BIOPSY, false)) {
biopsyTaken = biopsyGroup.readItemString(FIELD_BIOPSY_TAKEN, 0, false);
biopsyEvaluable = biopsyGroup.readItemString(FIELD_BIOPSY_EVALUABLE, 0, false);
}
for (final EcrfItemGroup biopsiesGroup : form.nonEmptyItemGroupsPerOID(ITEMGROUP_BIOPSIES, false)) {
final LocalDate date = biopsiesGroup.readItemDate(FIELD_BIOPSY_DATE, 0, DATE_FORMATTER, false);
final String location = biopsiesGroup.readItemString(FIELD_LOCATION, 0, false);
final String site = biopsiesGroup.readItemString(FIELD_SITE, 0, false);
final String siteOther = biopsiesGroup.readItemString(FIELD_SITE_OTHER, 0, false);
final String finalSite = (site == null || site.trim().toLowerCase().startsWith("other")) ? siteOther : site;
BiopsyData biopsy = ImmutableBiopsyData.of(date, biopsyTaken, biopsyEvaluable, finalSite, location, form.status(), form.locked());
// form needed to be created for every treatment response.
if (!isDuplicate(biopsies, biopsy) && !isEmpty(biopsy)) {
biopsies.add(biopsy);
}
}
}
}
return biopsies;
}
use of com.hartwig.hmftools.common.ecrf.datamodel.EcrfItemGroup 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.common.ecrf.datamodel.EcrfItemGroup in project hmftools by hartwigmedical.
the class BiopsyTreatmentResponseReader method read.
@NotNull
static List<BiopsyTreatmentResponseData> read(@NotNull final EcrfPatient patient) {
final List<BiopsyTreatmentResponseData> treatmentResponses = Lists.newArrayList();
for (final EcrfStudyEvent studyEvent : patient.studyEventsPerOID(STUDY_TREATMENT)) {
for (final EcrfForm form : studyEvent.nonEmptyFormsPerOID(FORM_TUMOR_MEASUREMENT, false)) {
// KODU: There are generally multiple assessment dates per tumor measurement (one per target lesion)
LocalDate assessmentDate = null;
for (final EcrfItemGroup itemGroup : form.nonEmptyItemGroupsPerOID(ITEMGROUP_MEASUREMENT, false)) {
final LocalDate date = itemGroup.readItemDate(FIELD_ASSESSMENT_DATE, 0, DATE_FORMATTER, false);
if (date != null) {
assessmentDate = date;
break;
}
}
LocalDate responseDate = null;
String measurementDone = null;
String boneOnlyDisease = null;
String response = null;
for (final EcrfItemGroup itemGroup : form.nonEmptyItemGroupsPerOID(ITEMGROUP_TUMOR_MEASUREMENT, false)) {
final LocalDate responseDateValue = itemGroup.readItemDate(FIELD_RESPONSE_DATE, 0, DATE_FORMATTER, false);
if (responseDateValue != null) {
responseDate = responseDateValue;
}
final String measurementDoneValue = itemGroup.readItemString(FIELD_MEASUREMENT_DONE, 0, false);
if (measurementDoneValue != null) {
measurementDone = measurementDoneValue;
}
final String boneOnlyDiseaseValue = itemGroup.readItemString(FIELD_BONE_ONLY_DISEASE, 0, false);
if (boneOnlyDiseaseValue != null) {
boneOnlyDisease = boneOnlyDiseaseValue;
}
final String responseValue = itemGroup.readItemString(FIELD_RESPONSE, 0, false);
if (responseValue != null) {
response = responseValue;
}
}
BiopsyTreatmentResponseData responseData = ImmutableBiopsyTreatmentResponseData.of(assessmentDate, responseDate, response, measurementDone, boneOnlyDisease, form.status(), form.locked());
if (!isEmpty(responseData)) {
treatmentResponses.add(responseData);
}
}
}
return treatmentResponses;
}
use of com.hartwig.hmftools.common.ecrf.datamodel.EcrfItemGroup in project hmftools by hartwigmedical.
the class CpctPatientReader method setDemographyData.
private void setDemographyData(@NotNull final ImmutableBaselineData.Builder builder, @NotNull final EcrfStudyEvent studyEvent) {
for (final EcrfForm demographyForm : studyEvent.nonEmptyFormsPerOID(FORM_DEMOGRAPHY, false)) {
for (final EcrfItemGroup demographyItemGroup : demographyForm.nonEmptyItemGroupsPerOID(ITEMGROUP_DEMOGRAPHY, false)) {
builder.gender(demographyItemGroup.readItemString(FIELD_SEX, 0, false));
builder.demographyStatus(demographyForm.status());
builder.demographyLocked(demographyForm.locked());
}
}
}
Aggregations