Skip to content

[ADE-56] - Upload Medical Report File for Easy Access #31

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

Merged
merged 11 commits into from
Mar 26, 2025
Merged

[ADE-56] - Upload Medical Report File for Easy Access #31

merged 11 commits into from
Mar 26, 2025

Conversation

jkestering-modus
Copy link
Collaborator

@jkestering-modus jkestering-modus commented Mar 24, 2025

Change

Implemented complete file upload functionality in the mobile app with the following features:

  • File Format Support: Added support for uploading medical reports in PDF, JPEG, and PNG formats
  • File Size Validation: Implemented size limits of 10MB for PDF files and 5MB for image files
  • Format Validation: Added validation to reject unsupported file formats with user-friendly error messages
  • Upload Progress: Implemented progress bar with time remaining indicator during file upload
  • Success Confirmation: Added success screen that appears after a successful upload

Does this PR introduce a breaking change?

No. This PR adds new functionality without affecting existing features.

What needs to be documented?

  • Supported file formats (PDF, JPEG, PNG)
  • File size limitations (10MB for PDFs, 5MB for images)
  • Upload process flow for end users
  • Error handling scenarios

Additional Comments

The implementation includes:

  • Error handling with user-friendly messages
  • File upload cancellation capability
  • Permission handling for mobile platforms (iOS/Android)
  • Estimated time remaining display during upload
  • Modal stays open after successful upload to allow users to view the success message

Testing Notes

Testing should cover:

  • Uploading valid files of each supported format
  • Attempting to upload files that exceed size limits
  • Attempting to upload unsupported file formats
  • Cancelling an upload mid-process
  • Testing on both web and mobile platforms

- Introduced UploadModal for handling file uploads with validation and progress tracking.
- Added useFileUpload hook to manage file selection, validation, and upload status.
- Updated UploadPage to integrate UploadModal and handle file upload requests.
- Added new assets for upload states and updated styles for UploadModal.
- Enhanced general.mdc with new image links for upload status visuals.
- Added uploadReport function to handle file uploads with progress tracking.
- Introduced UploadProgressCallback interface for progress updates.
- Updated TabNavigation and UploadPage components to navigate after successful uploads.
- Refactored UploadModal to support onUploadComplete callback.
- Created comprehensive tests for reportService and UploadModal to ensure functionality and error handling.
- Added file validation utilities and tests for various file types and sizes.
- Updated UploadModal.scss for enhanced styling, including background colors and padding adjustments.
- Replaced IonHeader and IonToolbar with a custom header for better layout control.
- Consolidated file size limit display into a single paragraph for clarity.
- Added new localization strings for upload functionality in English, Spanish, and French.
- Expanded reportService.test.ts with additional tests for uploadReport, fetchLatestReports, and fetchAllReports functions.
- Mocked axios for better control over API responses in tests.
- Updated localization strings in English, Spanish, and French for consistency, changing "try-again" to "tryAgain" and modifying no reports messages.
- Adjusted NoReportsMessage component to utilize updated translation keys.
@jkestering-modus jkestering-modus self-assigned this Mar 24, 2025
- Changed appId and appName to reflect new project branding.
- Added server configuration to allow navigation for all HTTP and HTTPS requests.
- Updated UploadModal.scss to enhance styling, including height adjustments and new success/error visual elements.
- Modified UploadModal.tsx to automatically start uploads upon file selection and added cancel functionality during uploads.
- Introduced new success and error states with improved user feedback.
- Enhanced tests for UploadModal to cover new features and ensure proper functionality.
- Deleted the HTTP entry from the allowNavigation array in capacitor.config.ts to enhance security by restricting navigation to HTTPS only.
- Implemented onKeyDown handler to trigger onClick when 'Enter' is pressed.
- Added role and tabIndex attributes for improved accessibility.
- Removed outdated @capacitor/filesystem dependency from package.json.
- Added @capacitor/filesystem version 6.0.2 to both package.json and package-lock.json for consistency.
- Updated @capacitor/ios version to 6.2.0 in both package.json and package-lock.json for alignment with other Capacitor packages.
@jkestering-modus jkestering-modus marked this pull request as ready for review March 25, 2025 20:19
Comment on lines 130 to 139
if (lowerFilename.includes('heart') || lowerFilename.includes('cardiac') || lowerFilename.includes('stress')) {
return ReportCategory.HEART;
} else if (lowerFilename.includes('brain') || lowerFilename.includes('neuro')) {
return ReportCategory.NEUROLOGICAL;
} else if (lowerFilename.includes('eye') || lowerFilename.includes('vision')) {
return ReportCategory.OFTALMOLOGICAL;
} else if (lowerFilename.includes('stomach') || lowerFilename.includes('gastro')) {
return ReportCategory.GASTRO;
} else if (lowerFilename.includes('bone') || lowerFilename.includes('joint')) {
return ReportCategory.ORTHOPEDIC;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I asked claude to improve this code and he did this

  // Convert filename to lowercase once for case-insensitive matching
  const lowerFilename = filename.toLowerCase();
  
  // Define mapping of keywords to categories
  const categoryKeywords = {
    [ReportCategory.HEART]: ['heart', 'cardiac', 'stress'],
    [ReportCategory.NEUROLOGICAL]: ['brain', 'neuro'],
    [ReportCategory.OPHTHALMOLOGICAL]: ['eye', 'vision', 'optic'],
    [ReportCategory.GASTRO]: ['stomach', 'gastro', 'digestive'],
    [ReportCategory.ORTHOPEDIC]: ['bone', 'joint', 'skeletal']
  };
  
  // Check each category
  for (const [category, keywords] of Object.entries(categoryKeywords)) {
    if (keywords.some(keyword => lowerFilename.includes(keyword))) {
      return category;
    }
  }
  
  // Default category if no match found
  return ReportCategory.OTHER;
}

- Introduced a new section in general.mdc outlining guidelines for determining categories based on keywords.
- Refactored the determineCategory function in reportService.ts to utilize a constant mapping object for improved readability and maintainability.
- Replaced multiple if-else statements with a more efficient approach using Array methods for keyword matching.
@GuidoBR GuidoBR merged commit d9a14c1 into main Mar 26, 2025
3 checks passed
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.

2 participants