Skip to content

Conversation

@isaacmujuni
Copy link

@isaacmujuni isaacmujuni commented Sep 3, 2025

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

This PR addresses several code quality issues and React warnings that were present in the OpenMRS ESM Patient Chart codebase:

Issues Fixed:

  1. Controlled/Uncontrolled Component Warning: Fixed React warnings about NumberInput components switching from uncontrolled to controlled state in the vitals-biometrics form
  2. Console Statements in Production: Wrapped all console.error and console.warn statements with development-only checks to prevent debug noise in production builds
  3. Test Environment Warnings: Improved error handling in the useOfflineVisit hook to reduce test warnings

Changes Made:

  • Vitals Biometrics Form: Removed defaultValue prop and ensured consistent controlled behavior with value={value ?? ''}
  • Error Handling: Added process.env.NODE_ENV === 'development' checks to all console statements across multiple packages
  • Common Library: Enhanced error handling in the offline visit functionality
  • Documentation: Updated .gitignore to exclude development documentation files

Files Modified:

  • packages/esm-patient-vitals-app/src/vitals-biometrics-form/vitals-biometrics-input.component.tsx
  • packages/esm-patient-notes-app/src/notes/visit-notes-form.workspace.tsx
  • packages/esm-patient-conditions-app/src/conditions/conditions-widget.component.tsx
  • packages/esm-patient-conditions-app/src/conditions/delete-condition.modal.tsx
  • packages/esm-patient-chart-app/src/mark-patient-deceased/mark-patient-deceased-form.workspace.tsx
  • packages/esm-patient-vitals-app/src/components/delete-vitals-biometrics-modal/delete-vitals-biometrics.modal.tsx
  • packages/esm-patient-chart-app/src/patient-chart/chart-review/chart-review.component.tsx
  • packages/esm-patient-chart-app/src/visit/hooks/useDefaultVisitLocation.tsx
  • packages/esm-patient-chart-app/src/visit/hooks/useVisitAttributeType.tsx
  • packages/esm-patient-orders-app/src/order-basket/order-basket.workspace.tsx
  • packages/esm-patient-orders-app/src/components/order-details-table.component.tsx
  • packages/esm-patient-chart-app/src/visit/visit-form/location-selector.component.tsx
  • packages/esm-patient-common-lib/src/offline/visit.ts
  • .gitignore

Screenshots

No UI changes were made - these are code quality improvements only.

Related Issue

No specific ticket exists for these code quality improvements.

Other

These changes improve the overall code quality and developer experience by:

  • Eliminating React warnings that could confuse developers
  • Ensuring production builds are clean without debug noise
  • Maintaining debugging capabilities for development environments
  • Following React best practices for controlled components

isaacmujuni and others added 18 commits September 3, 2025 13:08
…odal

- Added documentation files to .gitignore to prevent them from being tracked.
- Improved error logging in DeleteAllergyModal by conditionally logging errors only in development environment.
- Updated the error handling function to log errors conditionally, only in the development environment, for improved debugging without cluttering production logs.
- Updated the error logging mechanism to conditionally log messages only in the development environment, reducing noise in production logs.
- Updated the error handling in StartVisitButton to conditionally log errors only in the development environment, improving production log clarity.
- Updated the error handling in useDefaultVisitLocation to log errors conditionally, only in the development environment, improving clarity in production logs.
- Updated error handling in useVisitAttributeType to log errors conditionally, only in the development environment, improving clarity in production logs.
- Updated the error logging in LocationSelector to conditionally log warnings only in the development environment, improving clarity in production logs.
- Changed the import statement for ChartConfig to use TypeScript's 'type' keyword for improved type safety and clarity in the VisitSummaryComponent.
- Updated the error logging in ConditionsWidget to conditionally log errors only in the development environment, improving clarity in production logs.
- Updated the error handling in DeleteConditionModal to conditionally log errors only in the development environment, improving clarity in production logs.
- Updated the error handling in VisitNotesForm to conditionally log errors only in the development environment, improving clarity in production logs.
- Updated the error handling in OrderBasketItemActions to conditionally log errors only in the development environment, improving clarity in production logs.
- Updated the error handling in OrderPriceDetailsComponent to conditionally log errors only in the development environment, improving clarity in production logs.
- Updated the error handling in OrderBasket to conditionally log errors only in the development environment, improving clarity in production logs.
- Updated the error handling in DeleteVitalsAndBiometricsModal to conditionally log errors only in the development environment, improving clarity in production logs.
- Removed the defaultValue prop from NumberInput and ensured the value prop defaults to an empty string when undefined, improving input handling in the VitalsAndBiometricsInput component.
- Updated the error handling in useOfflineVisit to conditionally log errors only in the development environment, improving clarity in production logs.
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.

1 participant