Labs/Billing/Pharmacy/Tags/Identifiers
Adds
- Activity Definition
- Service Request
- Healthcare Service
- Observation Definition
- Specimen Definition
- Specimen
- Diagnostic Report
- Charge Item Definition
- Charge Item
- Account
- Invoice
- Product Knowledge
- Product
- Inventory Item
- Medication Dispense
- Inventory Stock Alerts
- Supply Request
- Supply Delivery
- Patient Identifiers
- Tag Management
- Resource Tagging Fundamentals
Summary by CodeRabbit
-
New Features
- Added comprehensive EMR models and APIs for activity definitions, healthcare services, observation definitions, service requests, specimens, charge items, accounts, invoices, payment reconciliations, diagnostic reports, medication dispenses, inventory items, products, product knowledge, supply requests, supply deliveries, patient identifiers, and tagging.
- Introduced facility-level discount and tax configuration with API support for setting monetary codes.
- Enhanced medication request functionality with requested product and dispense status tracking.
- Added batch operations and custom actions for service requests, diagnostic reports, invoices, and medication dispenses.
- Implemented detailed serialization/deserialization and nested resource expansion for complex data relations.
- Registered new API routes covering all introduced resources.
- Introduced advanced filtering, validation, and strict facility scoping across resources.
- Added authorization and permission handlers enforcing facility-scoped access control for new resource types.
- Provided new value sets for clinical and inventory coding standards.
- Added patient identifier configuration, caching, validation, and management integrated with patient records.
- Introduced monetary component models and synchronization logic for charge items, invoices, and accounts.
- Added inventory management features including supply deliveries, supply requests, inventory items, and product knowledge.
- Enabled synchronization of inventory availability based on supply deliveries and medication dispenses.
- Added support for managing patient identifiers within patient records, including transactional creation and update endpoints.
- Extended facility and organization models with discount-related fields and improved permission checks.
- Added tagging support for multiple resources with management APIs and filtering capabilities.
- Introduced comprehensive invoice management with status transitions, charge item attachments, and cancellation handling.
- Added detailed account balance synchronization and rebalance functionality.
- Enhanced medication dispense with charge item creation, inventory synchronization, and summary views.
- Added supply delivery and supply request management with validation and inventory integration.
- Included patient identifier configs with authorization and cache management.
- Added new patient tagging endpoints for instance and facility tags.
- Introduced filtering support for tags on querysets.
- Added new facility API endpoint to update monetary codes.
- Added default account creation logic for patients and facilities.
- Added synchronization utilities for charge items, invoices, accounts, and inventory items.
- Added support for converting activity and observation definitions to service requests and observations.
- Introduced tagging mixins and filters for resource tagging management.
- Added support for diagnostic report batch observation upserts.
- Added medication dispense summary endpoint grouped by encounters.
- Added supply delivery status handling with inventory synchronization.
- Added patient identifier caching and retrieval optimization.
- Added support for medication administration with administered product tracking.
-
Bug Fixes
- Corrected field name typos and schema inconsistencies across models and migrations.
- Fixed validation and uniqueness checks for patient identifier configs and tags.
- Resolved serialization inconsistencies by updating extra serialization methods to accept additional arguments.
- Fixed queryset filtering and authorization logic in encounter and medication request viewsets.
-
Documentation
- Added expert guidelines on Python and Django development for scalable web applications.
-
Chores
- Improved import organization and expanded wildcard imports.
- Updated environment configurations for questionnaire response sizes and monetary codes.
-
Style
- Added clarifying comments to enums and improved code readability.
-
Refactor
- Updated field types and validation logic for consistency and extensibility.
- Centralized and extended permission and authorization logic for new resource types.
- Refined serializer context handling and authorization checks in viewsets.
- Enhanced tagging management with base and specialized tag managers.
- Simplified swagger schema generation by refining list view detection.
-
Tests
- (Implicit) Strengthened model and API validation via Pydantic schemas and DRF filter sets.
This release significantly enhances clinical, financial, inventory, tagging, and patient identifier management capabilities, delivering robust tools for healthcare operations.
[!CAUTION]
Review failed
The pull request is closed.
📝 Walkthrough
Walkthrough
This update introduces extensive new EMR features, including tagging, inventory, billing, supply chain, and diagnostic modules. It adds dozens of Django models, Pydantic specs, DRF viewsets, authorization handlers, permission enums, and supporting utilities. Tagging is now supported across many resources. The codebase also gains new filter types, caching, monetary calculation logic, and expression evaluators for invoice and patient identifier numbering.
Changes
| File(s) / Path(s) | Change Summary |
|---|---|
.cursorignore, .cursorrules |
Add ignore rules and expert coding guidelines. |
care/emr/models/..., care/facility/models/facility.py |
Introduce new models: Account, ChargeItem, DiagnosticReport, HealthcareService, ActivityDefinition, InventoryItem, Invoice, MedicationDispense, ObservationDefinition, PatientIdentifierConfig, PaymentReconciliation, Product, ProductKnowledge, ServiceRequest, Specimen, SpecimenDefinition, SupplyRequest, SupplyDelivery, TagConfig, and add fields to Encounter, Patient, TokenBooking, MedicationRequest, MedicationAdministration. |
care/emr/api/viewsets/... |
Add DRF viewsets for all new models, implement CRUD, filtering, tagging, authorization, and custom actions for billing, inventory, supply, tagging, and patient identifiers. |
care/emr/resources/... |
Add Pydantic specs for all new models, enums for statuses, types, and categories, plus serialization/deserialization logic, value sets, and resource-specific utilities (e.g., charge item cost sync, invoice item sync, patient identifier evaluators). |
care/emr/tagging/..., care/utils/filters/... |
Implement generic tagging managers, tag filters, null/dummy filters for DRF. |
care/emr/locks/billing.py |
Add locking classes for account and invoice concurrency. |
care/emr/utils/... |
Add decimal serializer, expression evaluator, monetary code wrappers, and pydantic utilities. |
care/security/authorization/..., care/security/permissions/..., care/security/roles/role.py |
Introduce new authorization handlers and permission enums for all new resources, add PHARMACIST_ROLE, expand role lists for existing permissions. |
config/api_router.py |
Register new viewsets and routes for all new EMR modules. |
config/settings/base.py, config/settings/custom_limits.py |
Set global decimal context, add monetary code settings, and increase questionnaire response size limit. |
care/emr/management/commands/load_fixtures.py, data/questionnaire_fixtures.json |
Extend fixtures with lab definitions and new questionnaire. |
.vscode/launch.json, Pipfile, scripts/start.sh |
Update dev tooling: add evalidate dependency, expand launch configs, minor shell script tweak. |
TODO.md |
Add note on child location request filtering. |
| ... (dozens of resource spec and value set files) | Add/modify Pydantic models, enums, and value sets for new resource types, tagging, and inventory. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant DRFViewset
participant AuthorizationController
participant DjangoModel
participant TagManager
User->>DRFViewset: Create/Update Resource (e.g., ServiceRequest)
DRFViewset->>AuthorizationController: Check permission (facility/org scope)
AuthorizationController-->>DRFViewset: Permission granted/denied
DRFViewset->>DjangoModel: Validate/Save resource
DRFViewset->>TagManager: (Optional) Set/Remove tags
TagManager->>DjangoModel: Update tags field
DRFViewset-->>User: Return serialized resource (with tags, identifiers, etc.)
Possibly related PRs
- ohcnetwork/care#2874: Adds permission mixins to core EMR resource specs, exposing permissions in serialized output. Closely related as both PRs overhaul authorization and permission handling for EMR resources.
- ohcnetwork/care#2653: Removes summarization tasks and related code, focusing on facility summaries. Related in that both PRs perform sweeping changes to EMR resource management, though this PR is broader.
- ohcnetwork/care#2830: Adds
pyotpdependency for MFA, supporting TOTP functionality. Related as this PR also introduces new dependencies and expands authentication/authorization capabilities.
Suggested labels
waiting-for-review
Suggested reviewers
- praffq
Poem
In the land of EMR, new models now bloom,
Billing and tagging—oh, so much room!
Inventory and supply, diagnostics in tow,
Permissions and roles in a grand tableau.
If you thought it was simple, well, not anymore—
Reviewers, brace yourselves, this code is hardcore!
🏥💾💸
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
vigneshhari/labs
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai auto-generate unit teststo generate unit tests for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Codecov Report
Attention: Patch coverage is 64.00569% with 1772 lines in your changes missing coverage. Please review.
Project coverage is 54.99%. Comparing base (
ced1b8e) to head (6451238). Report is 243 commits behind head on develop.
Additional details and impacted files
@@ Coverage Diff @@
## develop #3004 +/- ##
===========================================
+ Coverage 51.20% 54.99% +3.78%
===========================================
Files 251 376 +125
Lines 11406 16181 +4775
Branches 1285 1685 +400
===========================================
+ Hits 5840 8898 +3058
- Misses 5545 7256 +1711
- Partials 21 27 +6
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.