Skip to content

Commit

Permalink
[US_MI][Workflows] Change completion event to be the review date for …
Browse files Browse the repository at this point in the history
…all scc opps (Recidiviz/recidiviz-data#29444)

## Description of the change

Instead of transfer out of solitary, which all scc opps contribute to,
change the completion even to be the review itself. This isn't a
strictly 1-1 relationship but nested.

- ALL observed SCC events (Scc, scc-warden, scc-add) should satisfy the
general scc opportunity and will do so with our current logic. For
example, if we observe a scc-add case note, we will use that to infer an
SCC review has happened, and that the ADD was there. Therefore, the
completion event for the general scc opp should include all three case
note types.

- For the warden and add opps, ONLY the scc-warden or scc-add case note
will satisfy that opp, and the completion event will just be that case
note type.

- All that means, if we observe the following # of opportunities granted
for each of the opps: 50 scc, 10 scc-warden, 5 scc-add. It does not mean
that 65 reviews happened, but that 50 happened, with 10 of those
including a warden, and 5 of those including an add.

## 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-data#29440

## 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: 08e5c8003f39541321a61cc8ddd60ad922411c17
  • Loading branch information
samanthahuff authored and Helper Bot committed May 15, 2024
1 parent ff7f0fe commit cadad61
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
ON pei.state_code = 'US_MI'
AND pei.id_type = 'US_MI_DOC'
AND pei.external_id = LTRIM(schedule.Offender_Number, '0')
WHERE schedule.Activity = 'SCC - Security Classification Committee'
WHERE schedule.Activity IN ('SCC - Security Classification Committee','SCC – ADD – 12 Month Review','SCC – Warden – 6 Month Review')
AND completed_date IS NOT NULL
AND DATE(completed_date) >= "2023-08-14"
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class WorkflowsOpportunityConfig:
opportunity_type="usMiSecurityClassificationCommitteeReview",
experiment_id="US_MI_COMPLETE_SECURITY_CLASSIFICATION_COMMITTEE_REVIEW_FORM",
opportunity_record_view_name="us_mi_complete_security_classification_committee_review_form_record_materialized",
task_completion_event=TaskCompletionEventType.TRANSFER_OUT_OF_SOLITARY_CONFINEMENT,
task_completion_event=TaskCompletionEventType.SECURITY_CLASSIFICATION_COMMITTEE_REVIEW,
source_filename="us_mi_complete_security_classification_committee_review_form_record.json",
export_collection_name="US_MI-securityClassificationCommitteeReview",
opportunity_type_path_str="securityClassificationCommitteeReview",
Expand All @@ -298,7 +298,7 @@ class WorkflowsOpportunityConfig:
opportunity_type="usMiAddInPersonSecurityClassificationCommitteeReview",
experiment_id="US_MI_COMPLETE_ADD_IN_PERSON_SECURITY_CLASSIFICATION_COMMITTEE_REVIEW_FORM",
opportunity_record_view_name="us_mi_complete_add_in_person_security_classification_committee_review_form_record_materialized",
task_completion_event=TaskCompletionEventType.TRANSFER_OUT_OF_SOLITARY_CONFINEMENT,
task_completion_event=TaskCompletionEventType.ADD_IN_PERSON_SECURITY_CLASSIFICATION_COMMITTEE_REVIEW,
source_filename="us_mi_complete_add_in_person_security_classification_committee_review_form_record.json",
export_collection_name="US_MI-addInPersonSecurityClassificationCommitteeReview",
opportunity_type_path_str="addInPersonSecurityClassificationCommitteeReview",
Expand All @@ -309,7 +309,7 @@ class WorkflowsOpportunityConfig:
opportunity_type="usMiWardenInPersonSecurityClassificationCommitteeReview",
experiment_id="US_MI_COMPLETE_WARDEN_IN_PERSON_SECURITY_CLASSIFICATION_COMMITTEE_REVIEW_FORM",
opportunity_record_view_name="us_mi_complete_warden_in_person_security_classification_committee_review_form_record_materialized",
task_completion_event=TaskCompletionEventType.TRANSFER_OUT_OF_SOLITARY_CONFINEMENT,
task_completion_event=TaskCompletionEventType.WARDEN_IN_PERSON_SECURITY_CLASSIFICATION_COMMITTEE_REVIEW,
source_filename="us_mi_complete_warden_in_person_security_classification_committee_review_form_record.json",
export_collection_name="US_MI-wardenInPersonSecurityClassificationCommitteeReview",
opportunity_type_path_str="wardenInPersonSecurityClassificationCommitteeReview",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Recidiviz - a data platform for criminal justice reform
# Copyright (C) 2023 Recidiviz, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# =============================================================================
"""Defines a view that shows all security committee classification review dates where the ADD was in person
for residents in Michigan.
"""
from recidiviz.calculator.query.state.dataset_config import ANALYST_VIEWS_DATASET
from recidiviz.common.constants.states import StateCode
from recidiviz.task_eligibility.task_completion_event_big_query_view_builder import (
StateSpecificTaskCompletionEventBigQueryViewBuilder,
TaskCompletionEventType,
)
from recidiviz.utils.environment import GCP_PROJECT_STAGING
from recidiviz.utils.metadata import local_project_id_override

_DESCRIPTION = """Defines a view that shows all security committee classification review dates where the ADD was in person
for residents in Michigan.
"""

_QUERY_TEMPLATE = """
SELECT
state_code,
person_id,
completion_event_date,
FROM `{project_id}.{analyst_views_dataset}.us_mi_add_in_person_security_classification_committee_review_materialized`
"""

VIEW_BUILDER: StateSpecificTaskCompletionEventBigQueryViewBuilder = StateSpecificTaskCompletionEventBigQueryViewBuilder(
state_code=StateCode.US_MI,
completion_event_type=TaskCompletionEventType.ADD_IN_PERSON_SECURITY_CLASSIFICATION_COMMITTEE_REVIEW,
description=_DESCRIPTION,
completion_event_query_template=_QUERY_TEMPLATE,
analyst_views_dataset=ANALYST_VIEWS_DATASET,
)

if __name__ == "__main__":
with local_project_id_override(GCP_PROJECT_STAGING):
VIEW_BUILDER.build_and_print()
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Recidiviz - a data platform for criminal justice reform
# Copyright (C) 2023 Recidiviz, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# =============================================================================
"""Defines a view that shows all security committee classification review dates for residents in Michigan.
"""
from recidiviz.calculator.query.state.dataset_config import ANALYST_VIEWS_DATASET
from recidiviz.common.constants.states import StateCode
from recidiviz.task_eligibility.task_completion_event_big_query_view_builder import (
StateSpecificTaskCompletionEventBigQueryViewBuilder,
TaskCompletionEventType,
)
from recidiviz.utils.environment import GCP_PROJECT_STAGING
from recidiviz.utils.metadata import local_project_id_override

_DESCRIPTION = """Defines a view that shows all security committee classification review dates for residents in Michigan.
"""

_QUERY_TEMPLATE = """
SELECT
state_code,
person_id,
completion_event_date,
FROM `{project_id}.{analyst_views_dataset}.us_mi_security_classification_committee_review_materialized`
"""

VIEW_BUILDER: StateSpecificTaskCompletionEventBigQueryViewBuilder = StateSpecificTaskCompletionEventBigQueryViewBuilder(
state_code=StateCode.US_MI,
completion_event_type=TaskCompletionEventType.SECURITY_CLASSIFICATION_COMMITTEE_REVIEW,
description=_DESCRIPTION,
completion_event_query_template=_QUERY_TEMPLATE,
analyst_views_dataset=ANALYST_VIEWS_DATASET,
)

if __name__ == "__main__":
with local_project_id_override(GCP_PROJECT_STAGING):
VIEW_BUILDER.build_and_print()
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Recidiviz - a data platform for criminal justice reform
# Copyright (C) 2023 Recidiviz, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# =============================================================================
"""Defines a view that shows all security committee classification review dates where the warden was in person for
residents in Michigan.
"""
from recidiviz.calculator.query.state.dataset_config import ANALYST_VIEWS_DATASET
from recidiviz.common.constants.states import StateCode
from recidiviz.task_eligibility.task_completion_event_big_query_view_builder import (
StateSpecificTaskCompletionEventBigQueryViewBuilder,
TaskCompletionEventType,
)
from recidiviz.utils.environment import GCP_PROJECT_STAGING
from recidiviz.utils.metadata import local_project_id_override

_DESCRIPTION = """Defines a view that shows all security committee classification review dates where the warden was
in person, for residents in Michigan.
"""

_QUERY_TEMPLATE = """
SELECT
state_code,
person_id,
completion_event_date,
FROM `{project_id}.{analyst_views_dataset}.us_mi_warden_in_person_security_classification_committee_review_materialized`
"""

VIEW_BUILDER: StateSpecificTaskCompletionEventBigQueryViewBuilder = StateSpecificTaskCompletionEventBigQueryViewBuilder(
state_code=StateCode.US_MI,
completion_event_type=TaskCompletionEventType.WARDEN_IN_PERSON_SECURITY_CLASSIFICATION_COMMITTEE_REVIEW,
description=_DESCRIPTION,
completion_event_query_template=_QUERY_TEMPLATE,
analyst_views_dataset=ANALYST_VIEWS_DATASET,
)

if __name__ == "__main__":
with local_project_id_override(GCP_PROJECT_STAGING):
VIEW_BUILDER.build_and_print()
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ class TaskCompletionEventType(Enum):
CUSTODY_LEVEL_DOWNGRADE_TO_MEDIUM_TRUSTEE = (
"CUSTODY_LEVEL_DOWNGRADE_TO_MEDIUM_TRUSTEE"
)
SECURITY_CLASSIFICATION_COMMITTEE_REVIEW = (
"SECURITY_CLASSIFICATION_COMMITTEE_REVIEW"
)
ADD_IN_PERSON_SECURITY_CLASSIFICATION_COMMITTEE_REVIEW = (
"ADD_IN_PERSON_SECURITY_CLASSIFICATION_COMMITTEE_REVIEW"
)
WARDEN_IN_PERSON_SECURITY_CLASSIFICATION_COMMITTEE_REVIEW = (
"WARDEN_IN_PERSON_SECURITY_CLASSIFICATION_COMMITTEE_REVIEW"
)
SUPERVISION_LEVEL_DOWNGRADE_BEFORE_INITIAL_CLASSIFICATION_REVIEW_DATE = (
"SUPERVISION_LEVEL_DOWNGRADE_BEFORE_INITIAL_CLASSIFICATION_REVIEW_DATE"
)
Expand Down

0 comments on commit cadad61

Please sign in to comment.