From e390f09c8aa8fba66fa80f7fb9b0398c46b6e060 Mon Sep 17 00:00:00 2001 From: samanthahuff <93396549+samanthahuff@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:18:38 +0000 Subject: [PATCH] [US_MI][Workflows] Take the greatest of sentencing length for early discharge from parole criteria (Recidiviz/recidiviz-data#29250) ## Description of the change We got feedback from trusted testers that clients were ineligible based on having a current offense with `(statute LIKE "750.110" OR statute LIKE "750.110A%")` and a sentence length > 15 years. Here we were calculating the date based on the difference between the `DATE_DIFF(projected_completion_date_max,effective_date,DAY)` which was giving us just under 15 years, despite the `max_sentence_length_days_calculated` being over 15 years. To resolve this issue we take the `GREATEST` of these fields. Tested in `shuff`. This change results in 14 fewer clients eligible for early discharge from parole out of 1187 clients. ## Type of change > All pull requests must have at least one of the following labels applied (otherwise the PR will fail): | Label | Description | |----------------------------- |----------------------------------------------------------------------------------------------------------- | | Type: Bug | non-breaking change that fixes an issue | | Type: Feature | non-breaking change that adds functionality | | Type: Breaking Change | fix or feature that would cause existing functionality to not work as expected | | Type: Non-breaking refactor | change addresses some tech debt item or prepares for a later change, but does not change functionality | | Type: Configuration Change | adjusts configuration to achieve some end related to functionality, development, performance, or security | | Type: Dependency Upgrade | upgrades a project dependency - these changes are not included in release notes | ## Related issues Closes #https://github.com/Recidiviz/recidiviz-dashboards/issues/5201 ## Checklists ### Development **This box MUST be checked by the submitter prior to merging**: - [x] **Double- and triple-checked that there is no Personally Identifiable Information (PII) being mistakenly added in this pull request** These boxes should be checked by the submitter prior to merging: - [ ] Tests have been written to cover the code changed/added as part of this pull request ### Code review These boxes should be checked by reviewers prior to merging: - [ ] This pull request has a descriptive title and information useful to a reviewer - [ ] Potential security implications or infrastructural changes have been considered, if relevant GitOrigin-RevId: e4428f8fad8e6debc64e259faeba4e068c5a3e81 --- ...l_supervision_past_early_discharge_date.py | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/recidiviz/task_eligibility/criteria/state_specific/us_mi/parole_dual_supervision_past_early_discharge_date.py b/recidiviz/task_eligibility/criteria/state_specific/us_mi/parole_dual_supervision_past_early_discharge_date.py index 7503cabd09..4d30b74452 100644 --- a/recidiviz/task_eligibility/criteria/state_specific/us_mi/parole_dual_supervision_past_early_discharge_date.py +++ b/recidiviz/task_eligibility/criteria/state_specific/us_mi/parole_dual_supervision_past_early_discharge_date.py @@ -51,22 +51,34 @@ AND compartment_level_2 IN ("PAROLE", "DUAL") AND inflow_from_level_2 NOT IN ("PAROLE", "DUAL") ), -sentences AS ( +sentences_preprocessed AS ( SELECT span.state_code, span.person_id, span.start_date, span.end_date, - ARRAY_AGG(DISTINCT statute IGNORE NULLS) AS statutes_being_served, - LOGICAL_OR(sent.life_sentence) AS any_life_sentence, - --checks for whether 750.110 and 750.110a are accompanied by a 15 year term - LOGICAL_OR(IF(((statute LIKE "750.110" OR statute LIKE "750.110A%") AND CAST(DATE_DIFF(projected_completion_date_max,effective_date,YEAR) AS INT64) >= 15), - true, false)) AS any_qualifying_statute_term + statute, + life_sentence, + GREATEST(DATE_DIFF(projected_completion_date_max,effective_date,DAY), + max_sentence_length_days_calculated)/365 AS term_length_years FROM `{{project_id}}.{{sessions_dataset}}.sentence_spans_materialized` span, UNNEST (sentences_preprocessed_id_array_actual_completion) AS sentences_preprocessed_id INNER JOIN `{{project_id}}.{{sessions_dataset}}.sentences_preprocessed_materialized` sent USING (state_code, person_id, sentences_preprocessed_id) WHERE state_code = "US_MI" +), +sentences AS ( + SELECT + state_code, + person_id, + start_date, + end_date, + ARRAY_AGG(DISTINCT statute IGNORE NULLS) AS statutes_being_served, + LOGICAL_OR(life_sentence) AS any_life_sentence, + --checks for whether 750.110 and 750.110a are accompanied by a 15 year term + LOGICAL_OR(IF((statute LIKE "750.110" OR statute LIKE "750.110A%") AND (term_length_years >= 15), + true, false)) AS any_qualifying_statute_term + FROM sentences_preprocessed GROUP BY 1, 2, 3, 4 ), sentence_statutes_preprocessed AS (