Search in sources :

Example 1 with EcrfForm

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

use of com.hartwig.hmftools.common.ecrf.datamodel.EcrfForm 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;
}
Also used : EcrfStudyEvent(com.hartwig.hmftools.common.ecrf.datamodel.EcrfStudyEvent) EcrfForm(com.hartwig.hmftools.common.ecrf.datamodel.EcrfForm) EcrfItemGroup(com.hartwig.hmftools.common.ecrf.datamodel.EcrfItemGroup) BiopsyData(com.hartwig.hmftools.patientdb.data.BiopsyData) ImmutableBiopsyData(com.hartwig.hmftools.patientdb.data.ImmutableBiopsyData) LocalDate(java.time.LocalDate) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with EcrfForm

use of com.hartwig.hmftools.common.ecrf.datamodel.EcrfForm 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;
}
Also used : ImmutableBiopsyTreatmentResponseData(com.hartwig.hmftools.patientdb.data.ImmutableBiopsyTreatmentResponseData) BiopsyTreatmentResponseData(com.hartwig.hmftools.patientdb.data.BiopsyTreatmentResponseData) EcrfStudyEvent(com.hartwig.hmftools.common.ecrf.datamodel.EcrfStudyEvent) EcrfForm(com.hartwig.hmftools.common.ecrf.datamodel.EcrfForm) EcrfItemGroup(com.hartwig.hmftools.common.ecrf.datamodel.EcrfItemGroup) LocalDate(java.time.LocalDate) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with EcrfForm

use of com.hartwig.hmftools.common.ecrf.datamodel.EcrfForm 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());
        }
    }
}
Also used : EcrfForm(com.hartwig.hmftools.common.ecrf.datamodel.EcrfForm) EcrfItemGroup(com.hartwig.hmftools.common.ecrf.datamodel.EcrfItemGroup)

Example 5 with EcrfForm

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

the class CpctPatientReader method setDeathData.

private static void setDeathData(@NotNull final ImmutableBaselineData.Builder builder, @NotNull final EcrfPatient patient) {
    for (final EcrfStudyEvent endStudyEvent : patient.studyEventsPerOID(STUDY_ENDSTUDY)) {
        for (final EcrfForm deathForm : endStudyEvent.nonEmptyFormsPerOID(FORM_DEATH, false)) {
            for (final EcrfItemGroup deathItemGroup : deathForm.nonEmptyItemGroupsPerOID(ITEMGROUP_DEATH, false)) {
                builder.deathDate(deathItemGroup.readItemDate(FIELD_DEATH_DATE, 0, DATE_FORMATTER, false));
                builder.deathStatus(deathForm.status());
                builder.deathLocked(deathForm.locked());
            }
        }
    }
}
Also used : EcrfStudyEvent(com.hartwig.hmftools.common.ecrf.datamodel.EcrfStudyEvent) EcrfForm(com.hartwig.hmftools.common.ecrf.datamodel.EcrfForm) EcrfItemGroup(com.hartwig.hmftools.common.ecrf.datamodel.EcrfItemGroup)

Aggregations

EcrfForm (com.hartwig.hmftools.common.ecrf.datamodel.EcrfForm)13 EcrfItemGroup (com.hartwig.hmftools.common.ecrf.datamodel.EcrfItemGroup)11 EcrfStudyEvent (com.hartwig.hmftools.common.ecrf.datamodel.EcrfStudyEvent)9 NotNull (org.jetbrains.annotations.NotNull)8 LocalDate (java.time.LocalDate)4 EcrfPatient (com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient)3 List (java.util.List)3 DrugData (com.hartwig.hmftools.patientdb.data.DrugData)2 ImmutableDrugData (com.hartwig.hmftools.patientdb.data.ImmutableDrugData)2 Assert.assertNotNull (org.junit.Assert.assertNotNull)2 EcrfDataField (com.hartwig.hmftools.common.ecrf.datamodel.EcrfDataField)1 EcrfResolveException (com.hartwig.hmftools.common.ecrf.datamodel.EcrfResolveException)1 FormStatusData (com.hartwig.hmftools.common.ecrf.formstatus.FormStatusData)1 FormStatusKey (com.hartwig.hmftools.common.ecrf.formstatus.FormStatusKey)1 ImmutableFormStatusKey (com.hartwig.hmftools.common.ecrf.formstatus.ImmutableFormStatusKey)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 ImmutableBiopsyData (com.hartwig.hmftools.patientdb.data.ImmutableBiopsyData)1 ImmutableBiopsyTreatmentData (com.hartwig.hmftools.patientdb.data.ImmutableBiopsyTreatmentData)1