-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4625465
commit 238ea77
Showing
12 changed files
with
71 additions
and
128 deletions.
There are no files selected for viewing
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
File renamed without changes.
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
5 changes: 3 additions & 2 deletions
5
packages/esm-patient-chart-app/src/encounter-list/components/tag.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
10 changes: 7 additions & 3 deletions
10
packages/esm-patient-chart-app/src/encounter-list/encounter-list.resource.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
1 change: 0 additions & 1 deletion
1
packages/esm-patient-chart-app/src/encounter-list/hooks/index.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,3 +1,2 @@ | ||
export * from './useEncounterRows'; | ||
export * from './useFormsJson'; | ||
export * from './usePatientDeathStatus'; |
38 changes: 9 additions & 29 deletions
38
packages/esm-patient-chart-app/src/encounter-list/hooks/useFormsJson.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,35 +1,15 @@ | ||
import { useEffect, useState } from 'react'; | ||
import useSWRImmutable from 'swr'; | ||
import { fetchOpenMRSForms } from '../encounter-list.resource'; | ||
import { type FormSchema } from '@openmrs/esm-form-engine-lib'; | ||
import useSWR from 'swr'; | ||
|
||
export function useFormsJson(formUuids: string[]) { | ||
const [openmrsForms, setOpenmrsForms] = useState<FormSchema[]>([]); | ||
const { data: responses, isLoading: isLoadingOpenmrsForms } = useSWRImmutable<any, Error>( | ||
formUuids, | ||
fetchOpenMRSForms, | ||
); | ||
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework'; | ||
import { Form } from '../types'; | ||
|
||
useEffect(() => { | ||
if (responses?.length) { | ||
setOpenmrsForms( | ||
responses | ||
.map((response, index) => { | ||
const match = | ||
response?.data ?? response?.data?.find((result) => !result.retired && result.name === formUuids[index]); | ||
if (!match) { | ||
console.error('Form not found: ' + formUuids[index]); | ||
return null; | ||
} | ||
return match; | ||
}) | ||
.filter(Boolean), | ||
); | ||
} | ||
}, [formUuids, responses]); | ||
export function useFormsJson(formUuid: string) { | ||
const url = `${restBaseUrl}/form/${formUuid}`; | ||
const { data, isLoading, error } = useSWR<{ data: Form }, Error>(url, openmrsFetch); | ||
|
||
return { | ||
formsJson: openmrsForms, | ||
isLoading: isLoadingOpenmrsForms, | ||
formsJson: data?.data ?? null, | ||
isLoading, | ||
error, | ||
}; | ||
} |
14 changes: 0 additions & 14 deletions
14
packages/esm-patient-chart-app/src/encounter-list/hooks/usePatientDeathStatus.ts
This file was deleted.
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
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.