Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eCourts Portal import proof of concept #431

Merged
merged 34 commits into from
Jan 14, 2024
Merged

eCourts Portal import proof of concept #431

merged 34 commits into from
Jan 14, 2024

Conversation

copelco
Copy link
Member

@copelco copelco commented Sep 9, 2023

Summary

  • Setup interface to install bookmarklet by dragging link from React app too Chrome bookmarks bar
  • Create simple ETL to receive bookmarklet POST request
  • Create simple parser interface using Beautiful Soup to parse name, county, and file number from record HTML
  • Start test suite using anonymized HTML record

Bookmarklet local dev

Inspiration:

Run tests

pytest -x dear_petition/portal/tests

Local development

python manage.py runserver
npm run start

Add bookmarklet to your bookmarks bar

Log in and drag the "Portal Importer (development)" button to your bookmarks bar.

Search and import from eCourts Portal

Visit https://portal-nc.tylertech.cloud/Portal/Home/Dashboard/29 and search for
a record. Click bookmark when on record detail page.

Watch output from Django server.

@copelco copelco linked an issue Oct 7, 2023 that may be closed by this pull request
Copy link
Contributor

@robert-w-gries robert-w-gries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments before testing

Comment on lines 2 to 3
"VD-District Dismissals w/o Leave by DA - No Plea Agreement",
"VD-Superior Dismissals w/o Leave by DA - No Plea Agreement",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Idea]

Maybe we can re-use the DISPOSITION_METHOD_CODE_MAP constant. More data needed to see if Tyler Technology always uses the codes here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to dear_petition.petition.constants.DISMISSED_DISPOSITION_METHODS

def import_portal_record(user, source):
"""Import eCourts Portal records into models."""
logger.info("Importing Portal record")
data = transform_portal_record(source)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're formalizing the common data between CIPRS and Portal, we should probably create a dataclass, something like ParsedOffenseRecord, that represents our parsed data.

@classmethod
def parse_date(cls, v):
if isinstance(v, str):
return dt.datetime.strptime(v, "%m/%d/%Y")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the date string is in a different format? That's a common issue with CIPRS pdfs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently it'll throw a ValidationError, which hopefully will get logged in Sentry.

>>> from dear_petition.portal.etl.parsers import case_info 
>>> case_info.Charge(
...     number=1,
...     offense="BREAK OR ENTER A MOTOR VEHICLE",
...     statute="14-56",
...     degree="FNC",
...     offense_date="January 1, 2001",
...     filed_date="01/09/2001",
... )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/copelco/projects/dear-petition/.direnv/python-3.8/lib/python3.8/site-packages/pydantic/main.py", line 164, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Charge
offense_date
  Value error, time data 'January 1, 2001' does not match format '%m/%d/%Y' [type=value_error, input_value='January 1, 2001', input_type=str]
    For further information visit https://errors.pydantic.dev/2.4/v/value_error

Comment on lines 35 to 38
if self.degree in ("FH", "FNC"):
severity = "FELONY"
elif self.degree in ("MNC",):
severity = "MISDEMEANOR"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use constants for all these strings


document.body.appendChild(iframe);

form.submit();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an alert("Successfully submitted case summary to Expunction Tool"); after form.submit()? And maybe we can clarify what they'd like to call the tool in case Expunction Tool isn't good

dear_petition/portal/etl/parsers/case_info.py Outdated Show resolved Hide resolved
logger = logging.getLogger(__name__)

COUNTY_COURT_REGEX = re.compile(r"([\w\s]+)(District|Superior) Court")
FILENO_REGEX = re.compile(r"\d\dCR\d\d\d\d\d\d-\d\d\d")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure the number of digits is always the same? The ciprs reader just grabs all characters that match \w+

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good question. I'm not sure. We need more records to see.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readme is out of date in regards to compressing the bookmarklet at least. Is everything else still relevant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@copelco copelco marked this pull request as ready for review January 9, 2024 23:35
@@ -0,0 +1,47 @@
const POST_URL = import.meta.env.MODE === 'development' ? 'http://localhost:8000' : 'https://www.durhamexpunction.org';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Replace with base window.location url

@copelco copelco merged commit 4e26d9b into master Jan 14, 2024
1 check passed
@copelco copelco deleted the portal-import branch January 14, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Import portal records
2 participants