|
|
|
@@ -1,10 +1,10 @@
|
|
|
|
|
version: 2
|
|
|
|
|
|
|
|
|
|
# The survival cohort, one query per rule, compiled and chained by `models cohorts build` like CaCu's surveillance
|
|
|
|
|
# cohort. The index is the first surgery, the first treatment: its report is where the catalog's covariates are
|
|
|
|
|
# (histology, receptors, size, nodes, margins), while the needle biopsy before it only says whether there is a
|
|
|
|
|
# carcinoma. Each exclusion reads only the index date and the data. Parameters: the `survival_cohort` var in
|
|
|
|
|
# dbt_project.yml.
|
|
|
|
|
# cohort. Whoever has the procedure of interest enters, a surgery of a kind in `surgeries`, its date the index: its
|
|
|
|
|
# report is where the catalog's covariates are (histology, receptors, size, nodes, margins), while the needle biopsy
|
|
|
|
|
# before it only says whether there is a carcinoma. The one filter keeps the patients in post-treatment. Parameters:
|
|
|
|
|
# the `survival_cohort` var in dbt_project.yml.
|
|
|
|
|
models:
|
|
|
|
|
- name: cama_survival_all_patients
|
|
|
|
|
description: Every patient of the domain.
|
|
|
|
@@ -18,12 +18,9 @@ models:
|
|
|
|
|
- name: cama_survival_index_date
|
|
|
|
|
description: First breast surgery of a kind in `surgeries`, if it falls in the recruitment window. Sets the index date.
|
|
|
|
|
config: {materialized: ephemeral, meta: {cohort: cama/cohorte_supervivencia, kind: index}}
|
|
|
|
|
- name: cama_survival_excl_prior_treatment
|
|
|
|
|
description: Radiotherapy or chemotherapy before the index surgery, so the surgery wasn't the first treatment.
|
|
|
|
|
config: {materialized: ephemeral, meta: {cohort: cama/cohorte_supervivencia, kind: exclusion, name: prior_treatment, order: 1}}
|
|
|
|
|
- name: cama_survival_excl_no_cancer
|
|
|
|
|
description: No invasive carcinoma by biopsy nor a malignant ICD-10 by the time the surgical report is due.
|
|
|
|
|
config: {materialized: ephemeral, meta: {cohort: cama/cohorte_supervivencia, kind: exclusion, name: no_cancer, order: 2}}
|
|
|
|
|
- name: cama_survival_excl_not_post_treatment
|
|
|
|
|
description: Not in post-treatment by the cut-off (no `escenario_postratamiento` in the timeline).
|
|
|
|
|
config: {materialized: ephemeral, meta: {cohort: cama/cohorte_supervivencia, kind: exclusion, name: not_post_treatment, order: 1}}
|
|
|
|
|
|
|
|
|
|
unit_tests:
|
|
|
|
|
- name: survival_index_is_the_first_therapeutic_surgery_in_the_window
|
|
|
|
@@ -35,7 +32,7 @@ unit_tests:
|
|
|
|
|
model: cama_survival_index_date
|
|
|
|
|
overrides:
|
|
|
|
|
vars:
|
|
|
|
|
survival_cohort: {recruitment_start: "2020-01-01", recruitment_end: "2027-01-01", cutoff: "2026-12-31", surgeries: ["SEGMENTECTOMIA", "MASTECTOMIA_TOTAL"], cancer_grades: ["CARCINOMA_INVASOR"], cancer_icd10: ["C504"], report_window_days: 90}
|
|
|
|
|
survival_cohort: {recruitment_start: "2020-01-01", recruitment_end: "2027-01-01", cutoff: "2026-12-31", surgeries: ["SEGMENTECTOMIA", "MASTECTOMIA_TOTAL"]}
|
|
|
|
|
given:
|
|
|
|
|
- input: ref('cama_linea_de_tiempo')
|
|
|
|
|
format: sql
|
|
|
|
@@ -52,12 +49,15 @@ unit_tests:
|
|
|
|
|
rows: |
|
|
|
|
|
select 1 as pac_id, '2023-03-01' as fecha_indice, 'cx' as indice_fuente_tabla, 'b' as indice_fuente_id
|
|
|
|
|
union all select 2, '2024-05-05', 'cx', 'c'
|
|
|
|
|
- name: survival_prior_treatment_flags_a_neoadjuvant_course
|
|
|
|
|
- name: survival_keeps_only_patients_in_post_treatment
|
|
|
|
|
description: >
|
|
|
|
|
Pins down: patient 1 had chemotherapy and patient 2 radiotherapy before the index surgery, so both are flagged;
|
|
|
|
|
patient 3's radiotherapy is on the index date and patient 4's after it, so neither is. Fails if the rule stops
|
|
|
|
|
reading both treatments or counts a course on the day of surgery.
|
|
|
|
|
model: cama_survival_excl_prior_treatment
|
|
|
|
|
Pins down: patient 1 entered post-treatment before the cut-off, so she stays; patient 2 is only in control,
|
|
|
|
|
patient 3's post-treatment starts after the cut-off and patient 4 has no scenario, so the three are flagged.
|
|
|
|
|
Fails if the filter reads another scenario or ignores the cut-off.
|
|
|
|
|
model: cama_survival_excl_not_post_treatment
|
|
|
|
|
overrides:
|
|
|
|
|
vars:
|
|
|
|
|
survival_cohort: {recruitment_start: "2020-01-01", recruitment_end: "2027-01-01", cutoff: "2026-12-31", surgeries: ["SEGMENTECTOMIA"]}
|
|
|
|
|
given:
|
|
|
|
|
- input: ref('cama_survival_index_date')
|
|
|
|
|
format: sql
|
|
|
|
@@ -67,39 +67,11 @@ unit_tests:
|
|
|
|
|
- input: ref('cama_linea_de_tiempo')
|
|
|
|
|
format: sql
|
|
|
|
|
rows: |
|
|
|
|
|
select 1 as pac_id, '2023-11-01' as fecha, 'quimioterapia' as tipo
|
|
|
|
|
union all select 2, '2024-01-15', 'radioterapia'
|
|
|
|
|
union all select 3, '2024-03-01', 'radioterapia'
|
|
|
|
|
union all select 4, '2024-05-01', 'quimioterapia'
|
|
|
|
|
select 1 as pac_id, '2024-03-10' as fecha, 'escenario_postratamiento' as tipo
|
|
|
|
|
union all select 2, '2024-02-01', 'escenario_control'
|
|
|
|
|
union all select 3, '2027-02-01', 'escenario_postratamiento'
|
|
|
|
|
expect:
|
|
|
|
|
rows:
|
|
|
|
|
- {pac_id: 1}
|
|
|
|
|
- {pac_id: 2}
|
|
|
|
|
- name: survival_no_cancer_waits_for_the_surgical_report
|
|
|
|
|
description: >
|
|
|
|
|
Pins down: patient 1's needle biopsy before surgery is invasive and patient 2's surgical report, 30 days after,
|
|
|
|
|
is too, so neither is flagged; patient 3's invasive report comes after the 90-day window and patient 4 only has a
|
|
|
|
|
benign biopsy, so both are; patient 5 has a malignant ICD-10 note, which is enough. Fails if the window, the
|
|
|
|
|
grades or the ICD-10 list stop applying.
|
|
|
|
|
model: cama_survival_excl_no_cancer
|
|
|
|
|
overrides:
|
|
|
|
|
vars:
|
|
|
|
|
survival_cohort: {recruitment_start: "2020-01-01", recruitment_end: "2027-01-01", cutoff: "2026-12-31", surgeries: ["SEGMENTECTOMIA"], cancer_grades: ["CARCINOMA_INVASOR"], cancer_icd10: ["C504"], report_window_days: 90}
|
|
|
|
|
given:
|
|
|
|
|
- input: ref('cama_survival_index_date')
|
|
|
|
|
format: sql
|
|
|
|
|
rows: |
|
|
|
|
|
select 1 as pac_id, '2024-03-01' as fecha_indice union all select 2, '2024-03-01'
|
|
|
|
|
union all select 3, '2024-03-01' union all select 4, '2024-03-01' union all select 5, '2024-03-01'
|
|
|
|
|
- input: ref('cama_linea_de_tiempo')
|
|
|
|
|
format: sql
|
|
|
|
|
rows: |
|
|
|
|
|
select 1 as pac_id, '2024-02-01' as fecha, 'biopsia' as tipo, 'CARCINOMA_INVASOR' as valor_codigo
|
|
|
|
|
union all select 2, '2024-03-31', 'biopsia', 'CARCINOMA_INVASOR'
|
|
|
|
|
union all select 3, '2024-07-15', 'biopsia', 'CARCINOMA_INVASOR'
|
|
|
|
|
union all select 4, '2024-03-20', 'biopsia', 'BENIGNO'
|
|
|
|
|
union all select 5, '2024-02-20', 'nota_medica', 'C504'
|
|
|
|
|
expect:
|
|
|
|
|
rows:
|
|
|
|
|
- {pac_id: 3}
|
|
|
|
|
- {pac_id: 4}
|
|
|
|
|