Skip to content

(fix) Resolve TypeError crash in getWardMetrics when spreading undefined patient arrays - #2590

Open
Abhishek2005-ard wants to merge 2 commits into
openmrs:mainfrom
Abhishek2005-ard:fix-ward-metrics-spread-crash
Open

(fix) Resolve TypeError crash in getWardMetrics when spreading undefined patient arrays#2590
Abhishek2005-ard wants to merge 2 commits into
openmrs:mainfrom
Abhishek2005-ard:fix-ward-metrics-spread-crash

Conversation

@Abhishek2005-ard

@Abhishek2005-ard Abhishek2005-ard commented Jun 21, 2026

Copy link
Copy Markdown

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 is based on designs, which are linked or shown either in the Jira ticket or the description below. (See also: Styleguide)
  • My work includes tests or is validated by existing tests.

Summary

This PR resolves a TypeError crash that occurs in getWardMetrics when attempting to spread iterables (like wardUnadmittedPatientsWithBed.values()) or mapped patient arrays that may evaluate to undefined.

The function was refactored to extract iterables safely using Array.from() with proper optional chaining to prevent undefined property access. Additionally, falsy/undefined values are explicitly filtered out using .filter(Boolean) when constructing the allPatients array, ensuring that downstream demographic metrics do not crash by accessing .person on undefined patient records.

Screenshots

N/A

Related Issue

N/A

Other

N/A

@Abhishek2005-ard Abhishek2005-ard changed the title resolve TypeError crash in getWardMetrics when spreading undefined patient arrays (fix) Resolve TypeError crash in getWardMetrics when spreading undefined patient arrays Jun 21, 2026
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