generated from METS-Programme/esm-ugandaemr-template-app
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use configurable profiles for registries (#8)
Use configurable profiles for registries
- Loading branch information
Showing
5 changed files
with
49 additions
and
32 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
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
59 changes: 39 additions & 20 deletions
59
packages/esm-patient-registration-app/src/patient-verification/verification-constants.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,20 +1,39 @@ | ||
export const patientRegistries = [ | ||
{ | ||
uuid: '84242661-aadf-42e4-9431-bf8afefb4433', | ||
id: 1, | ||
name: 'Client Registry (CR)', | ||
url: 'http://165.232.114.52:8085/hapi-fhir-jpaserver', | ||
}, | ||
{ | ||
uuid: '', | ||
id: 2, | ||
name: 'Shared Health Record (SHR)', | ||
url: 'http://165.227.170.84:9091', | ||
}, | ||
{ | ||
uuid: '', | ||
id: 3, | ||
name: 'Cross Border Registry (CBR)', | ||
url: 'http://ea-shr-url', | ||
}, | ||
]; | ||
import useSWR from 'swr'; | ||
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework'; | ||
|
||
declare type fhirProfile = { | ||
uuid: string; | ||
name: string; | ||
url: string; | ||
profileEnabled: boolean; | ||
profileSearchable: boolean; | ||
}; | ||
|
||
export function useGetPatientRegistries() { | ||
const apiUrl = `${restBaseUrl}/syncfhirprofile`; | ||
const { data, error, isLoading } = useSWR<{ data: { results: any } }, Error>(apiUrl, openmrsFetch); | ||
return { | ||
patientRegistries: data ? mapDataElements(data?.data['results']) : [], | ||
isError: error, | ||
isLoadingFhirProfiles: isLoading, | ||
}; | ||
} | ||
|
||
export function mapDataElements(dataArray: Array<Record<string, string>>) { | ||
const arrayToReturn: Array<fhirProfile> = []; | ||
if (dataArray) { | ||
dataArray.map((profile: Record<string, any>) => { | ||
if (profile?.profileEnabled && profile?.searchable) { | ||
arrayToReturn.push({ | ||
name: profile?.name, | ||
uuid: profile?.uuid, | ||
url: profile?.searchURL, | ||
profileEnabled: profile?.profileEnabled, | ||
profileSearchable: profile?.searchable, | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
return arrayToReturn; | ||
} |
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