Skip to content

remove Patient.record circular dependency#270

Merged
ericbuckley merged 3 commits into
mainfrom
fix/176-remove-record-circular-dep
Apr 3, 2025
Merged

remove Patient.record circular dependency#270
ericbuckley merged 3 commits into
mainfrom
fix/176-remove-record-circular-dep

Conversation

@ericbuckley

@ericbuckley ericbuckley commented Mar 31, 2025

Copy link
Copy Markdown
Collaborator

Description

Removing the circular dependency between models/mpi.py and schemas/pii.py. pii.py now depends on mpi.py, but not vice-versa.

Related Issues

closes #176

Additional Notes

The circular dependency didn't cause any issues, as the mpi.py module imported all of its pii.py dependencies in functions rather than at the top of the module, but this is a hack. Having two modules depend on each other opens potentials for errors during refactors, or could lead to more spaghetti code if attempt to use PIIRecord in mpi.py for other uses.

  • pii.PIIRecord created 2 new methods for converting a Patient into a PIIRecord and back. PIIRecord.from_patient and PIIRecord.to_data.
  • To reduce the number of times in which we convert a Patient object to a PIIRecord, the matching function signatures have been updated to accept two PIIRecord for comparison, rather than a PIIRecord and Patient.

<--------------------- REMOVE THE LINES BELOW BEFORE MERGING --------------------->

Checklist

Please review and complete the following checklist before submitting your pull request:

  • I have ensured that the pull request is of a manageable size, allowing it to be reviewed within a single session.
  • I have reviewed my changes to ensure they are clear, concise, and well-documented.
  • I have updated the documentation, if applicable.
  • I have added or updated test cases to cover my changes, if applicable.
  • I have minimized the number of reviewers to include only those essential for the review.

Checklist for Reviewers

Please review and complete the following checklist during the review process:

  • The code follows best practices and conventions.
  • The changes implement the desired functionality or fix the reported issue.
  • The tests cover the new changes and pass successfully.
  • Any potential edge cases or error scenarios have been considered.

@ericbuckley ericbuckley added the qa Technical improvements to increase code quality label Mar 31, 2025
@ericbuckley ericbuckley self-assigned this Mar 31, 2025
@codecov

codecov Bot commented Mar 31, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.93%. Comparing base (b5dc520) to head (f4efa4a).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #270      +/-   ##
==========================================
+ Coverage   97.84%   97.93%   +0.09%     
==========================================
  Files          33       33              
  Lines        1807     1789      -18     
==========================================
- Hits         1768     1752      -16     
+ Misses         39       37       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ericbuckley ericbuckley marked this pull request as ready for review March 31, 2025 21:55

@bamader bamader left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good catch! As an added bonus, I like the from_patient function in schemas now more than model_construct (pure semantics, I know, but from_X is a common functional construct so I think it's more readable, just gravy).

@ericbuckley ericbuckley merged commit cfa718e into main Apr 3, 2025
@ericbuckley ericbuckley deleted the fix/176-remove-record-circular-dep branch April 3, 2025 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qa Technical improvements to increase code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Patient.record dependency

2 participants