Skip to content

Commit

Permalink
[US_MI][Workflows] Take the greatest of sentencing length for early d…
Browse files Browse the repository at this point in the history
…ischarge 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 #Recidiviz/recidiviz-dashboards#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
  • Loading branch information
samanthahuff authored and Helper Bot committed May 10, 2024
1 parent 4775699 commit e390f09
Showing 1 changed file with 18 additions and 6 deletions.
Expand Up @@ -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 (
Expand Down

0 comments on commit e390f09

Please sign in to comment.