Skip to content

Conversation

@rahu1ramesh
Copy link
Contributor

JIRA -> BN-47

This PR adds functionality to display a patient's allergies on the dashboard, ensuring all allergies are clearly presented with relevant details.

Key Features

  • Allergies Details: Displays Reaction(s), Status, Severity and Provider with Recorded Date details.
  • Additional Information: Displays notes and highlights the row in red if it is a allergy of Severity severe.

Implementation Details

  • useAllergies Hook: Fetches allergies data from the OpenMRS FHIR AllergyIntolerance endpoint.
  • Allergies Service: Transforms FHIR data for structured UI rendering.
  • Allergies Table Component: Displays conditions in a clear, tabular format.
  • Date Utility: Added interim default date format
  • Testing & Type Definitions: Includes unit tests, integration tests, and TypeScript type definitions.

Next Steps

  • A separate card will be created to refine the UX.

Screenshot 2025-04-02 at 2 29 04 PM

const { allergies, loading, error } = useAllergies(patientUUID);

// Define table headers
const headers = useMemo(
Copy link
Member

Choose a reason for hiding this comment

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

What is the need for useMemo here ? this is a simple constant with no calculation involved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you defined the headers array directly in the render function (i.e., without useMemo), a new array reference would be created on every render. Even though the contents are the same, React (or child components) may interpret the new reference as a change — especially if the child component (like ExpandableDataTable) is using React.memo() or does deep equality checks to avoid re-renders.

import {
FhirAllergyIntolerance,
FhirAllergyIntoleranceBundle,
} from '../types/allergy';
Copy link
Member

Choose a reason for hiding this comment

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

Can we not use @types ??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we should, missed it.

import React, { useMemo } from 'react';
import { Tag } from '@carbon/react';
import { ExpandableDataTable } from '../../components/expandableDataTable/ExpandableDataTable';
import { usePatientUUID } from '../../hooks/usePatientUUID';
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't all the following imports use alias ?

@@ -0,0 +1,283 @@
import React from 'react';
import { renderHook, act, waitFor } from '@testing-library/react';
import { useAllergies } from '../useAllergies';
Copy link
Member

Choose a reason for hiding this comment

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

Use @hooks ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this a test for useAllergies available in the same sub folder, using an alias is an overkill.

* @param delimiters - Optional string of delimiter characters (default: " -", space and hyphen)
* @returns The string in capital case
*/
export function capitalize(input: string, delimiters: string = ' -'): string {
Copy link
Member

Choose a reason for hiding this comment

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

Captialize is confusing. The result of this function is sentenceCase not capitalCase. Can we think of a better method naming ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The result of the function would be "Foo Bar" for an input of "foo bar". Sentence case is when only the first character is in uppercase and the rest is all in lower (eg- "Foo bar").

@rahu1ramesh rahu1ramesh requested a review from mohan-13 April 10, 2025 10:49
@mohan-13 mohan-13 merged commit 7cecb0c into main Apr 11, 2025
2 checks passed
@mohan-13 mohan-13 deleted the BN-47 branch April 11, 2025 04:14
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.

3 participants