Skip to content

Commit

Permalink
(feat) : Switch to using kenyaemr custom endpoint to fetch patient …
Browse files Browse the repository at this point in the history
…from HIE
  • Loading branch information
donaldkibet committed Oct 23, 2024
1 parent 3558cdf commit 475bf3f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 123 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
import { add, capitalize } from 'lodash-es';
import capitalize from 'lodash-es/capitalize';
import { type PatientIdentifierValue, type FormValues } from '../../patient-registration/patient-registration.types';
import { type MapperConfig, type HIEPatient, type ErrorResponse } from './hie-types';
import { getConfig } from '@openmrs/esm-framework';
import { type RegistrationConfig } from '../../config-schema';
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
import { v4 } from 'uuid';
/**
* Represents a client for interacting with a Health Information Exchange (HIE) resource.
* @template T - The type of the resource being fetched.
*/
class HealthInformationExchangeClient<T> {
async fetchResource(resourceType: string, params: Record<string, string>): Promise<T> {
const {
hieClientRegistry: { baseUrl, encodedCredentials },
} = await getConfig<RegistrationConfig>('@kenyaemr/esm-patient-registration-app');
const urlParams = new URLSearchParams(params);
const response = await fetch(`${baseUrl}${resourceType}?${urlParams}`, {
headers: new Headers({
Authorization: `Basic ${encodedCredentials}`,
}),
});
const [identifierType, identifierValue] = Object.entries(params)[0];
const url = `${restBaseUrl}/kenyaemr/getSHAPatient/${identifierValue}/${identifierType}`;

const response = await openmrsFetch(url);
return response.json();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from 'react';
import { type FetchResponse, fhirBaseUrl, openmrsFetch, useDebounce } from '@openmrs/esm-framework';
import { type LocationEntry, type LocationResponse } from '@openmrs/esm-service-queues-app/src/types';
import { type LocationEntry, type LocationResponse } from '@kenyaemr/esm-service-queues-app/src/types';
import useSWR from 'swr';

interface UseLocationsResult {
Expand Down
12 changes: 3 additions & 9 deletions packages/esm-patient-registration-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
"deathdayInvalidDate": "Death date and time cannot be before the birthday",
"deathdayIsRequired": "Death date is required when the patient is marked as deceased.",
"deathdayNotInTheFuture": "",
"cityVillage": "City",
"continue": "Continue",
"createNewPatient": "Create new patient",
"dateOfBirth": "Date of birth",
"deathSection": "Death Info",
"deathTimeFormatInvalid": "Time format is invalid",
"deathTimeFormatRequired": "Time format is required",
Expand Down Expand Up @@ -100,14 +96,10 @@
"obsFieldUnknownDatatype": "Concept for obs field '{{fieldDefinitionId}}' has unknown datatype '{{datatypeName}}'",
"optional": "optional",
"optionalIdentifierLabel": "{{identifierName}} (optional)",
"originFacilityCode": "Origin facility code",
"originFacilityName": "Origin facility name",
"other": "Other",
"patientDetailsFound": "Patient information found in the registry, do you want to use the information to continue with registration?",
"patientName": "Patient name",
"patientNameKnown": "Patient's Name is Known?",
"refreshOrContactAdmin": "Try refreshing the page or contact your system administrator",
"registerPatient": "Register patient",
"patientNotFound": "The patient records could not be found in Client registry, do you want to continue to create and post patient to registry",
"patientRegistrationBreadcrumb": "Patient Registration",
"patientVerificationFromHIE": "Patient verification from HIE",
Expand All @@ -131,7 +123,9 @@
"searchAddress": "Search address",
"searchClientRegistry": "Search client registry",
"searchIdentifierPlaceholder": "Search identifier",
"searchingRegistry": "Searching registry...",
"searchLocationPersonAttribute": "Search location",
"searchRegistry": "Search registry",
"selectAnOption": "Select an option",
"selectCountry": "Select country",
"selectIdentifierType": "Select identifier type",
Expand All @@ -153,4 +147,4 @@
"viewFullResponse": "View full response",
"yearsEstimateRequired": "Estimated years required",
"yes": "Yes"
}
}
101 changes: 0 additions & 101 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2853,23 +2853,6 @@ __metadata:
languageName: node
linkType: hard

"@openmrs/esm-active-visits-app@workspace:packages/esm-active-visits-app":
version: 0.0.0-use.local
resolution: "@openmrs/esm-active-visits-app@workspace:packages/esm-active-visits-app"
dependencies:
"@carbon/react": "npm:~1.37.0"
lodash-es: "npm:^4.17.15"
webpack: "npm:^5.74.0"
peerDependencies:
"@openmrs/esm-framework": 5.x
dayjs: 1.x
react: ^18.1.0
react-dom: ^18.1.0
react-i18next: 11.x
swr: 2.x
languageName: unknown
linkType: soft

"@openmrs/esm-api@npm:5.8.2-pre.2411":
version: 5.8.2-pre.2411
resolution: "@openmrs/esm-api@npm:5.8.2-pre.2411"
Expand Down Expand Up @@ -2920,42 +2903,6 @@ __metadata:
languageName: node
linkType: hard

"@openmrs/esm-appointments-app@workspace:packages/esm-appointments-app":
version: 0.0.0-use.local
resolution: "@openmrs/esm-appointments-app@workspace:packages/esm-appointments-app"
dependencies:
"@carbon/react": "npm:~1.37.0"
formik: "npm:^2.2.9"
lodash-es: "npm:^4.17.15"
webpack: "npm:^5.74.0"
yup: "npm:^0.32.11"
peerDependencies:
"@openmrs/esm-framework": 5.x
"@openmrs/esm-patient-common-lib": 8.x
react: 18.x
react-i18next: 11.x
react-router-dom: 6.x
swr: 2.x
languageName: unknown
linkType: soft

"@openmrs/esm-bed-management-app@workspace:packages/esm-bed-management-app":
version: 0.0.0-use.local
resolution: "@openmrs/esm-bed-management-app@workspace:packages/esm-bed-management-app"
dependencies:
"@carbon/react": "npm:~1.37.0"
lodash-es: "npm:^4.17.15"
webpack: "npm:^5.74.0"
peerDependencies:
"@openmrs/esm-framework": 5.x
dayjs: 1.x
react: 18.x
react-i18next: 11.x
react-router-dom: 6.x
swr: 2.x
languageName: unknown
linkType: soft

"@openmrs/esm-config@npm:5.8.2-pre.2411":
version: 5.8.2-pre.2411
resolution: "@openmrs/esm-config@npm:5.8.2-pre.2411"
Expand Down Expand Up @@ -3203,22 +3150,6 @@ __metadata:
languageName: unknown
linkType: soft

"@openmrs/esm-patient-search-app@workspace:packages/esm-patient-search-app":
version: 0.0.0-use.local
resolution: "@openmrs/esm-patient-search-app@workspace:packages/esm-patient-search-app"
dependencies:
"@carbon/react": "npm:~1.37.0"
lodash-es: "npm:^4.17.15"
webpack: "npm:^5.74.0"
peerDependencies:
"@openmrs/esm-framework": 5.x
react: ^18.1.0
react-i18next: 11.x
react-router-dom: 6.x
swr: 2.x
languageName: unknown
linkType: soft

"@openmrs/esm-react-utils@npm:5.8.2-pre.2411":
version: 5.8.2-pre.2411
resolution: "@openmrs/esm-react-utils@npm:5.8.2-pre.2411"
Expand Down Expand Up @@ -3261,22 +3192,6 @@ __metadata:
languageName: node
linkType: hard

"@openmrs/esm-service-queues-app@workspace:packages/esm-service-queues-app":
version: 0.0.0-use.local
resolution: "@openmrs/esm-service-queues-app@workspace:packages/esm-service-queues-app"
dependencies:
"@carbon/react": "npm:~1.37.0"
lodash-es: "npm:^4.17.15"
webpack: "npm:^5.74.0"
peerDependencies:
"@openmrs/esm-framework": 5.x
react: ^18.1.0
react-i18next: 11.x
react-router-dom: 6.x
swr: 2.x
languageName: unknown
linkType: soft

"@openmrs/esm-state@npm:5.8.2-pre.2411":
version: 5.8.2-pre.2411
resolution: "@openmrs/esm-state@npm:5.8.2-pre.2411"
Expand Down Expand Up @@ -3346,22 +3261,6 @@ __metadata:
languageName: node
linkType: hard

"@openmrs/esm-ward-app@workspace:packages/esm-ward-app":
version: 0.0.0-use.local
resolution: "@openmrs/esm-ward-app@workspace:packages/esm-ward-app"
dependencies:
"@carbon/react": "npm:~1.37.0"
lodash-es: "npm:^4.17.15"
webpack: "npm:^5.74.0"
peerDependencies:
"@openmrs/esm-framework": 5.x
react: ^18.1.0
react-i18next: 11.x
react-router-dom: 6.x
swr: 2.x
languageName: unknown
linkType: soft

"@openmrs/webpack-config@npm:5.8.2-pre.2411":
version: 5.8.2-pre.2411
resolution: "@openmrs/webpack-config@npm:5.8.2-pre.2411"
Expand Down

0 comments on commit 475bf3f

Please sign in to comment.