-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat) Improvement to care panels and patient enrollments section (#50)
* (feat) Improvement to care panels and patient enrollments section * (upgrade yarn to 4.0.1 to fix build
- Loading branch information
1 parent
4a5d634
commit 557adec
Showing
21 changed files
with
7,083 additions
and
7,855 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
nodeLinker: node-modules | ||
compressionLevel: mixed | ||
|
||
enableGlobalCache: false | ||
|
||
plugins: | ||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs | ||
spec: "@yarnpkg/plugin-interactive-tools" | ||
nodeLinker: node-modules | ||
|
||
yarnPath: .yarn/releases/yarn-3.6.0.cjs | ||
yarnPath: .yarn/releases/yarn-4.0.1.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 41 additions & 32 deletions
73
packages/esm-care-panel-app/src/care-panel/care-panel.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ | |
justify-content: space-between; | ||
width: 100%; | ||
align-items: center; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 9 additions & 25 deletions
34
packages/esm-care-panel-app/src/hooks/useEnrollmentHistory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,18 @@ | ||
import { openmrsFetch } from '@openmrs/esm-framework'; | ||
import useSWR from 'swr'; | ||
import groupBy from 'lodash/groupBy'; | ||
import { openmrsFetch } from '@openmrs/esm-framework'; | ||
|
||
export const useEnrollmentHistory = (patientUuid: string) => { | ||
const enrollmentHistoryUrl = `/ws/rest/v1/kenyaemr/patientHistoricalEnrollment?patientUuid=${patientUuid}`; | ||
const { data, mutate, error, isLoading } = useSWR<{ data: Array<any> }>(enrollmentHistoryUrl, openmrsFetch); | ||
|
||
const groupedEnrollment = groupDataByProgram(data?.data ?? []); | ||
const { data, isValidating, error, isLoading } = useSWR<{ data: Array<Record<string, any>> }>( | ||
enrollmentHistoryUrl, | ||
openmrsFetch, | ||
); | ||
|
||
return { | ||
data: groupedEnrollment ?? [], | ||
isError: error, | ||
error: error, | ||
isLoading: isLoading, | ||
enrollments: groupBy(data?.data ?? [], 'programName') ?? [], | ||
isValidating, | ||
}; | ||
}; | ||
|
||
function groupDataByProgram(data) { | ||
const groupedData = []; | ||
|
||
data.forEach((item) => { | ||
const programName = item.programName; | ||
const status = item.active ? 'Active' : 'Inactive'; | ||
|
||
const existingGroup = groupedData.find((group) => group.programName === programName && group.status === status); | ||
|
||
if (existingGroup) { | ||
existingGroup.data.push(item); | ||
} else { | ||
groupedData.push({ programName, status, data: [item] }); | ||
} | ||
}); | ||
|
||
return groupedData; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.