Skip to content

Commit

Permalink
🐛 fix(medical-records-formatter.js): import get function from lodash …
Browse files Browse the repository at this point in the history
…to fix undefined error

The `get` function from lodash is imported to fix an undefined error that occurs when accessing nested properties in the `recordsFieldFormatter` function. This ensures that the `field` property is properly accessed from each record in the `results` array.
  • Loading branch information
jofftiquez committed Aug 29, 2023
1 parent 3d16736 commit 41ba603
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/medical-records-formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
addMonths,
differenceInDays,
} from 'date-fns';
import { cloneDeep, isEmpty } from 'lodash';
import { cloneDeep, isEmpty, get } from 'lodash';

const dentalExamFields = ['8', '7', '6', '5', '4', '3', '2', '1'];

Expand Down Expand Up @@ -71,7 +71,7 @@ export const recordsFieldFormatter = (records, options) => {
const { field, type, subtype, joinerToken = ', ' } = options;
const results = getRecords(records, type, subtype);
if (!results?.length) return '';
return results.map(record => record[field]).filter(Boolean).join(joinerToken);
return results.map(record => get(record, field)).filter(Boolean).join(joinerToken);
};

export const formatSocialHistory = (record) => {
Expand Down

0 comments on commit 41ba603

Please sign in to comment.