Search in sources :

Example 1 with FORM_TUMOR_MEASUREMENT

use of com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentResponseReader.FORM_TUMOR_MEASUREMENT in project hmftools by hartwigmedical.

the class PatientValidator method validateTreatmentResponses.

@NotNull
@VisibleForTesting
static List<ValidationFinding> validateTreatmentResponses(@NotNull final String patientIdentifier, @NotNull final List<BiopsyTreatmentData> treatments, @NotNull final List<BiopsyTreatmentResponseData> responses) {
    final List<ValidationFinding> findings = Lists.newArrayList();
    for (int i = 0; i < responses.size(); i++) {
        findings.addAll(validateTreatmentResponse(patientIdentifier, responses.get(i), i == 0));
    }
    Collections.sort(treatments);
    Collections.sort(responses);
    if (treatments.isEmpty() && !responses.isEmpty()) {
        findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, FORM_TREATMENT, "treatment response filled in, but treatment data missing", FormStatusState.UNKNOWN, false));
    }
    if (!treatments.isEmpty() && !responses.isEmpty()) {
        final LocalDate firstResponseDate = responses.get(0).date();
        final LocalDate firstTreatmentStart = treatments.get(0).startDate();
        if (firstResponseDate != null && firstTreatmentStart != null && firstResponseDate.isAfter(firstTreatmentStart)) {
            findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, fields(FORM_TREATMENT, FORM_TUMOR_MEASUREMENT), "first (baseline) measurement date is after first treatment start", FormStatusState.best(treatments.get(0).formStatus(), responses.get(0).formStatus()), treatments.get(0).formLocked() || responses.get(0).formLocked(), "first treatment response: " + firstResponseDate + "; first treatment start: " + firstTreatmentStart));
        }
    }
    final List<BiopsyTreatmentData> treatmentsMissingResponse = treatments.stream().filter(treatment -> shouldHaveResponse(treatment) && !hasResponse(treatment.id(), responses)).collect(Collectors.toList());
    if (treatmentsMissingResponse.size() > 0) {
        findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, FORM_TUMOR_MEASUREMENT, "no treatment response for at least 1 treatment", FormStatusState.UNKNOWN, false, "treatments " + treatmentsMissingResponse.stream().map(BiopsyTreatmentData::toString).collect(Collectors.toList()) + " should have response since they lasted more than " + Config.IMMEDIATE_TREATMENT_END_THRESHOLD + " days and started more than " + Config.START_DATE_RESPONSE_THRESHOLD + " days ago"));
    }
    return findings;
}
Also used : Comparator.naturalOrder(java.util.Comparator.naturalOrder) FIELD_DEATH_DATE(com.hartwig.hmftools.patientdb.readers.CpctPatientReader.FIELD_DEATH_DATE) FORM_TUMOR_MEASUREMENT(com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentResponseReader.FORM_TUMOR_MEASUREMENT) FORM_BIOPS(com.hartwig.hmftools.patientdb.readers.BiopsyReader.FORM_BIOPS) FIELD_BIOPSY_DATE(com.hartwig.hmftools.patientdb.readers.BiopsyReader.FIELD_BIOPSY_DATE) TreatmentData(com.hartwig.hmftools.patientdb.data.TreatmentData) Comparator.nullsLast(java.util.Comparator.nullsLast) Duration(java.time.Duration) FIELD_PRE_DRUG(com.hartwig.hmftools.patientdb.readers.PreTreatmentReader.FIELD_PRE_DRUG) FIELD_PRETREATMENT_GIVEN(com.hartwig.hmftools.patientdb.readers.PreTreatmentReader.FIELD_PRETREATMENT_GIVEN) FIELD_PRIMARY_TUMOR_LOCATION_OTHER(com.hartwig.hmftools.patientdb.readers.CpctPatientReader.FIELD_PRIMARY_TUMOR_LOCATION_OTHER) Patient(com.hartwig.hmftools.patientdb.data.Patient) BiopsyData(com.hartwig.hmftools.patientdb.data.BiopsyData) Collectors(java.util.stream.Collectors) FIELD_RESPONSE_DATE(com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentResponseReader.FIELD_RESPONSE_DATE) FIELD_DRUG(com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentReader.FIELD_DRUG) ValidationFinding(com.hartwig.hmftools.common.ecrf.datamodel.ValidationFinding) List(java.util.List) FIELD_PRIMARY_TUMOR_LOCATION(com.hartwig.hmftools.patientdb.readers.CpctPatientReader.FIELD_PRIMARY_TUMOR_LOCATION) FORM_TREATMENT(com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentReader.FORM_TREATMENT) LocalDate(java.time.LocalDate) FIELD_RESPONSE(com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentResponseReader.FIELD_RESPONSE) Strings(org.apache.logging.log4j.util.Strings) BiopsyTreatmentData(com.hartwig.hmftools.patientdb.data.BiopsyTreatmentData) NotNull(org.jetbrains.annotations.NotNull) BiopsyTreatmentResponseData(com.hartwig.hmftools.patientdb.data.BiopsyTreatmentResponseData) FIELD_DRUG_START(com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentReader.FIELD_DRUG_START) FIELD_ASSESSMENT_DATE(com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentResponseReader.FIELD_ASSESSMENT_DATE) FIELD_BIRTH_YEAR3(com.hartwig.hmftools.patientdb.readers.CpctPatientReader.FIELD_BIRTH_YEAR3) FIELD_BIRTH_YEAR2(com.hartwig.hmftools.patientdb.readers.CpctPatientReader.FIELD_BIRTH_YEAR2) Config(com.hartwig.hmftools.patientdb.Config) FIELD_TREATMENT_GIVEN(com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentReader.FIELD_TREATMENT_GIVEN) FIELD_PRERADIOTHERAPY_GIVEN(com.hartwig.hmftools.patientdb.readers.PreTreatmentReader.FIELD_PRERADIOTHERAPY_GIVEN) FIELD_MEASUREMENT_DONE(com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentResponseReader.FIELD_MEASUREMENT_DONE) PreTreatmentData(com.hartwig.hmftools.patientdb.data.PreTreatmentData) FIELD_SITE_OTHER(com.hartwig.hmftools.patientdb.readers.BiopsyReader.FIELD_SITE_OTHER) FIELD_HOSPITAL2(com.hartwig.hmftools.patientdb.readers.CpctPatientReader.FIELD_HOSPITAL2) FIELD_INFORMED_CONSENT_DATE(com.hartwig.hmftools.patientdb.readers.CpctPatientReader.FIELD_INFORMED_CONSENT_DATE) FIELD_HOSPITAL1(com.hartwig.hmftools.patientdb.readers.CpctPatientReader.FIELD_HOSPITAL1) Lists(com.google.common.collect.Lists) Comparator.comparing(java.util.Comparator.comparing) BaselineData(com.hartwig.hmftools.patientdb.data.BaselineData) FIELD_BIRTH_YEAR1(com.hartwig.hmftools.patientdb.readers.CpctPatientReader.FIELD_BIRTH_YEAR1) FIELD_SITE(com.hartwig.hmftools.patientdb.readers.BiopsyReader.FIELD_SITE) DrugData(com.hartwig.hmftools.patientdb.data.DrugData) FIELD_LOCATION(com.hartwig.hmftools.patientdb.readers.BiopsyReader.FIELD_LOCATION) FIELD_REGISTRATION_DATE2(com.hartwig.hmftools.patientdb.readers.CpctPatientReader.FIELD_REGISTRATION_DATE2) FIELD_REGISTRATION_DATE1(com.hartwig.hmftools.patientdb.readers.CpctPatientReader.FIELD_REGISTRATION_DATE1) FIELD_RADIOTHERAPY_GIVEN(com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentReader.FIELD_RADIOTHERAPY_GIVEN) FIELD_SEX(com.hartwig.hmftools.patientdb.readers.CpctPatientReader.FIELD_SEX) FIELD_DRUG_END(com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentReader.FIELD_DRUG_END) FormStatusState(com.hartwig.hmftools.common.ecrf.formstatus.FormStatusState) CuratedTreatment(com.hartwig.hmftools.patientdb.data.CuratedTreatment) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) FIELD_DRUG_OTHER(com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentReader.FIELD_DRUG_OTHER) ValidationFinding(com.hartwig.hmftools.common.ecrf.datamodel.ValidationFinding) BiopsyTreatmentData(com.hartwig.hmftools.patientdb.data.BiopsyTreatmentData) LocalDate(java.time.LocalDate) VisibleForTesting(com.google.common.annotations.VisibleForTesting) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Lists (com.google.common.collect.Lists)1 ValidationFinding (com.hartwig.hmftools.common.ecrf.datamodel.ValidationFinding)1 FormStatusState (com.hartwig.hmftools.common.ecrf.formstatus.FormStatusState)1 Config (com.hartwig.hmftools.patientdb.Config)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 CuratedTreatment (com.hartwig.hmftools.patientdb.data.CuratedTreatment)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 TreatmentData (com.hartwig.hmftools.patientdb.data.TreatmentData)1 FIELD_BIOPSY_DATE (com.hartwig.hmftools.patientdb.readers.BiopsyReader.FIELD_BIOPSY_DATE)1 FIELD_LOCATION (com.hartwig.hmftools.patientdb.readers.BiopsyReader.FIELD_LOCATION)1 FIELD_SITE (com.hartwig.hmftools.patientdb.readers.BiopsyReader.FIELD_SITE)1 FIELD_SITE_OTHER (com.hartwig.hmftools.patientdb.readers.BiopsyReader.FIELD_SITE_OTHER)1 FORM_BIOPS (com.hartwig.hmftools.patientdb.readers.BiopsyReader.FORM_BIOPS)1 FIELD_DRUG (com.hartwig.hmftools.patientdb.readers.BiopsyTreatmentReader.FIELD_DRUG)1