From 475bf3fe383656f3186e00dc8ba0f173fef57f59 Mon Sep 17 00:00:00 2001 From: Donald Kibet Date: Wed, 23 Oct 2024 15:21:59 +0300 Subject: [PATCH] (feat) : Switch to using `kenyaemr` custom endpoint to fetch patient from HIE --- .../hie-client-registry/hie-resource.ts | 17 +-- ...cation-person-attribute-field.resource.tsx | 2 +- .../translations/en.json | 12 +-- yarn.lock | 101 ------------------ 4 files changed, 9 insertions(+), 123 deletions(-) diff --git a/packages/esm-patient-registration-app/src/client-registry/hie-client-registry/hie-resource.ts b/packages/esm-patient-registration-app/src/client-registry/hie-client-registry/hie-resource.ts index 9f6bd6a31..38f082d76 100644 --- a/packages/esm-patient-registration-app/src/client-registry/hie-client-registry/hie-resource.ts +++ b/packages/esm-patient-registration-app/src/client-registry/hie-client-registry/hie-resource.ts @@ -1,8 +1,7 @@ -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. @@ -10,16 +9,10 @@ import { v4 } from 'uuid'; */ class HealthInformationExchangeClient { async fetchResource(resourceType: string, params: Record): Promise { - const { - hieClientRegistry: { baseUrl, encodedCredentials }, - } = await getConfig('@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(); } } diff --git a/packages/esm-patient-registration-app/src/patient-registration/field/person-attributes/location-person-attribute-field.resource.tsx b/packages/esm-patient-registration-app/src/patient-registration/field/person-attributes/location-person-attribute-field.resource.tsx index 5ce5d8837..3d5e2edda 100644 --- a/packages/esm-patient-registration-app/src/patient-registration/field/person-attributes/location-person-attribute-field.resource.tsx +++ b/packages/esm-patient-registration-app/src/patient-registration/field/person-attributes/location-person-attribute-field.resource.tsx @@ -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 { diff --git a/packages/esm-patient-registration-app/translations/en.json b/packages/esm-patient-registration-app/translations/en.json index 4ffa93b34..bdc086da0 100644 --- a/packages/esm-patient-registration-app/translations/en.json +++ b/packages/esm-patient-registration-app/translations/en.json @@ -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", @@ -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", @@ -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", @@ -153,4 +147,4 @@ "viewFullResponse": "View full response", "yearsEstimateRequired": "Estimated years required", "yes": "Yes" -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 9bb45aae9..5e3fbb9dc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" @@ -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" @@ -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" @@ -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"