Skip to content

Commit

Permalink
Merge branch 'main' into feat-edit-user-role-scope
Browse files Browse the repository at this point in the history
  • Loading branch information
ojwanganto authored Jan 21, 2025
2 parents 794aefd + 2a96b0e commit a93b96f
Show file tree
Hide file tree
Showing 19 changed files with 128 additions and 339 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"*.{js,jsx,ts,tsx}": "eslint --cache --fix"
},
"dependencies": {
"@carbon/charts-react": "^1.13.33",
"@hookform/resolvers": "^3.1.1",
"ace-builds": "^1.36.5",
"classnames": "^2.3.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-admin-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
"url": "https://github.com/palladiumkenya/kenyaemr-esm-3.x/issues"
},
"dependencies": {
"@carbon/react": "^1.72.0",
"lodash-es": "^4.17.15",
"react-to-print": "^2.14.13"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "5.x",
"react": "^18.1.0",
"react-i18next": "11.x",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-billing-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
"url": "https://github.com/palladiumkenya/kenyaemr-esm-core/issues"
},
"dependencies": {
"@carbon/react": "^1.72.0",
"lodash-es": "^4.17.15",
"react-to-print": "^2.14.13"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "5.x",
"react": "^18.1.0",
"react-i18next": "11.x",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ const SHANumberValidity: React.FC<SHANumberValidityProps> = ({ paymentMethod, pa

const { data, isLoading: isLoadingHIEEligibility, error } = useSHAEligibility(patientUuid, shaIdentificationNumber);

const isRegisteredOnSHA = Boolean(data?.coverageEndDate) && Boolean(data?.coverageStartDate);
const isNotRegisteredOnSHA = data?.status === 0;
const isRegisteredOnSHA = data?.status === 1;

const isActive = isRegisteredOnSHA
? isWithinInterval(new Date(), {
Expand Down Expand Up @@ -76,10 +75,10 @@ const SHANumberValidity: React.FC<SHANumberValidityProps> = ({ paymentMethod, pa
);
}

if (isNotRegisteredOnSHA) {
if (!isRegisteredOnSHA) {
return (
<InlineNotification
title={t('HIEVerificationFailure', 'HIE verification failure')}
title={t('hieVerificationFailure', 'HIE verification failure')}
subtitle={`${data?.message ?? ''}.${data?.possibleSolution ?? ''}`}
className={styles.missingSHANumber}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-billing-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"finalDiagnosis": "Final Diagnosis",
"formTitle": "Fill in the form details",
"generatedMessage": "The invoice has been electronically generated and is a valid document. It was created by {{userName}} on {{date}} at {{time}}",
"hieVerificationFailure": "HIE verification failure",
"home": "Home",
"identifier": "Identifier",
"inactive": "Inactive",
Expand Down Expand Up @@ -200,7 +201,6 @@
"paymentPoints": "Payment Points",
"payments": "Payments",
"paymentType": "Payment Type",
"pendingHIEVerification": "Pending HIE verification",
"Phone Number": "Phone Number",
"pickLabRequest": "Pick Lab Request",
"policyNumber": "Policy number",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-care-panel-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
"url": "https://github.com/palladiumkenya/kenyaemr-esm-core/issues"
},
"dependencies": {
"@carbon/react": "^1.72.0",
"lodash-es": "^4.17.15",
"react-to-print": "^2.14.13"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "5.x",
"react": "^18.1.0",
"react-i18next": "11.x",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-cross-border-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"url": "https://github.com/palladiumkenya/kenyaemr-esm-core/issues"
},
"dependencies": {
"@carbon/react": "^1.72.0",
"lodash-es": "^4.17.15"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "5.x",
"react": "^18.1.0",
"react-i18next": "11.x",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-lab-manifest-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
"url": "https://github.com/palladiumkenya/kenyaemr-esm-core/issues"
},
"dependencies": {
"@carbon/react": "^1.72.0",
"lodash-es": "^4.17.15",
"react-to-print": "^2.14.13"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "5.x",
"react": "^18.1.0",
"react-i18next": "11.x",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-morgue-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
"url": "https://github.com/palladiumkenya/kenyaemr-esm-core/issues"
},
"dependencies": {
"@carbon/react": "^1.72.0",
"lodash-es": "^4.17.15",
"react-to-print": "^2.14.13"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "5.x",
"react": "^18.1.0",
"react-i18next": "11.x",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-clinical-view-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
},
"dependencies": {
"@carbon/charts-react": "^1.5.2",
"@carbon/react": "^1.72.0",
"d3": "^7.6.1",
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "5.x",
"react": "^18.1.0",
"react-i18next": "11.x",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-flags-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"url": "https://github.com/palladiumkenya/kenyaemr-esm-core/issues"
},
"dependencies": {
"@carbon/react": "^1.72.0",
"lodash-es": "^4.17.15"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "5.x",
"react": "^18.1.0",
"react-i18next": "11.x",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-pharmacy-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
"url": "https://github.com/palladiumkenya/kenyaemr-esm-core/issues"
},
"dependencies": {
"@carbon/react": "^1.72.0",
"lodash-es": "^4.17.15",
"react-to-print": "^2.14.13"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "5.x",
"react": "^18.1.0",
"react-i18next": "11.x",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-providers-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
"url": "https://github.com/palladiumkenya/kenyaemr-esm-3.x/issues"
},
"dependencies": {
"@carbon/react": "^1.72.0",
"lodash-es": "^4.17.15",
"react-to-print": "^2.14.13"
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "5.x",
"react": "^18.1.0",
"react-i18next": "11.x",
Expand Down
114 changes: 59 additions & 55 deletions packages/esm-providers-app/src/modal/provider-sync-modal.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,105 +21,109 @@ const HWRSyncModal: React.FC<HWRSyncModalProps> = ({ close, provider }) => {
const { t } = useTranslation();
const [syncLoading, setSyncLoading] = useState(false);

const config = useConfig<ConfigObject>();
const {
providerNationalIdUuid,
licenseBodyUuid,
licenseExpiryDateUuid,
passportNumberUuid,
licenseNumberUuid,
identifierTypes,
} = useConfig<ConfigObject>();
phoneNumberUuid,
qualificationUuid,
providerAddressUuid,
providerHieFhirReference,
} = config;

const providerNationalId = provider.attributes.find((attr) => attr.attributeType.uuid === providerNationalIdUuid);
const registrationNumber = provider.attributes.find((attr) => attr.attributeType.uuid === licenseBodyUuid);
const passPortNumber = provider.attributes.find((attr) => attr.attributeType.uuid === passportNumberUuid);
const attributeMapping = {
[identifierTypes[0]?.key]:
provider.attributes.find((attr) => attr.attributeType.uuid === providerNationalIdUuid)?.value || '--',
[identifierTypes[1]?.key]:
provider.attributes.find((attr) => attr.attributeType.uuid === licenseBodyUuid)?.value || '--',
[identifierTypes[2]?.key]:
provider.attributes.find((attr) => attr.attributeType.uuid === passportNumberUuid)?.value || '--',
};

const [searchHWR, setSearchHWR] = useState({
identifierType: identifierTypes[0]?.key,
identifier: providerNationalId?.value,
identifier: attributeMapping[identifierTypes[0]?.key],
});

const handleIdentifierTypeChange = (selectedItem: { key: string; name: string } | null) => {
const selectedKey = selectedItem?.key ?? '';
const identifierValue =
selectedKey === identifierTypes[0]?.key
? providerNationalId?.value || '--'
: selectedKey === identifierTypes[1]?.key
? registrationNumber?.value || '--'
: selectedKey === identifierTypes[2]?.key
? passPortNumber?.value || '--'
: '';

setSearchHWR((prev) => ({
...prev,
identifierType: selectedKey,
identifier: identifierValue,
identifier: attributeMapping[selectedKey] || '',
}));
};

const isSearchDisabled = () => {
const { identifierType } = searchHWR;
return (
(identifierType === identifierTypes[0]?.key && !providerNationalId?.value) ||
(identifierType === identifierTypes[1]?.key && !registrationNumber?.value) ||
(identifierType === identifierTypes[2]?.key && !passPortNumber?.value)
);
};
const isSearchDisabled = () => !searchHWR.identifier;

const handleSync = async () => {
try {
setSyncLoading(true);

const healthWorker: Practitioner = await searchHealthCareWork(searchHWR.identifierType, searchHWR.identifier);
const licenseNumber = healthWorker.entry[0]?.resource.identifier?.find((id) =>
id.type?.coding?.some((code) => code.code === 'license-number'),
)?.value;
const regNumber = healthWorker?.entry[0]?.resource.identifier?.find((id) =>
id.type?.coding?.some((code) => code.code === 'board-registration-number'),
)?.value;
const licenseDate = formatDate(
new Date(
healthWorker?.entry[0]?.resource.identifier?.find((id) =>
id.type?.coding?.some((code) => code.code === 'license-number'),
)?.period?.end,
const resource = healthWorker.entry[0]?.resource;

const extractedAttributes = {
licenseNumber: resource?.identifier?.find((id) =>
id.type?.coding?.some((code) => code.code === 'license-number'),
)?.value,
regNumber: resource?.identifier?.find((id) =>
id.type?.coding?.some((code) => code.code === 'board-registration-number'),
)?.value,
licenseDate: formatDate(
new Date(
resource?.identifier?.find((id) =>
id.type?.coding?.some((code) => code.code === 'license-number'),
)?.period?.end,
),
),
);
phoneNumber: resource?.telecom?.find((contact) => contact.system === 'phone')?.value,
email: resource?.telecom?.find((contact) => contact.system === 'email')?.value,
qualification:
resource?.qualification?.[0]?.code?.coding?.[0]?.display ||
resource?.extension?.find((ext) => ext.url === 'https://ts.kenya-hie.health/Codesystem/specialty')
?.valueCodeableConcept?.coding?.[0]?.display,
};

const updatableAttributes = [
{
attributeType: licenseNumberUuid,
value: licenseNumber,
},
{
attributeType: licenseBodyUuid,
value: regNumber,
},
{
attributeType: licenseExpiryDateUuid,
value: parseDate(licenseDate),
},
];
{ attributeType: licenseNumberUuid, value: extractedAttributes.licenseNumber },
{ attributeType: licenseBodyUuid, value: extractedAttributes.regNumber },
{ attributeType: licenseExpiryDateUuid, value: parseDate(extractedAttributes.licenseDate) },
{ attributeType: phoneNumberUuid, value: extractedAttributes.phoneNumber },
{ attributeType: qualificationUuid, value: extractedAttributes.qualification },
{ attributeType: providerHieFhirReference, value: JSON.stringify(healthWorker) },
{ attributeType: providerAddressUuid, value: extractedAttributes.email },
].filter((attr) => attr.value !== undefined && attr.value !== null && attr.value !== '');

await Promise.all(
updatableAttributes.map((attr) => {
const _attribute = provider.attributes.find((at) => at.attributeType.uuid === attr.attributeType)?.uuid;
if (!_attribute) {
const existingAttribute = provider.attributes.find(
(at) => at.attributeType.uuid === attr.attributeType,
)?.uuid;
if (!existingAttribute) {
return createProviderAttribute(attr, provider.uuid);
}
return updateProviderAttributes({ value: attr.value }, provider.uuid, _attribute);
return updateProviderAttributes({ value: attr.value }, provider.uuid, existingAttribute);
}),
);

mutate((key) => typeof key === 'string' && key.startsWith('/ws/rest/v1/provider'));
showSnackbar({ title: 'Success', kind: 'success', subtitle: t('syncmsg', 'Account synced successfully!') });
showSnackbar({
title: 'Success',
kind: 'success',
subtitle: t('syncmsg', 'Account synced successfully!'),
});
close();
} catch (err) {
const { identifierType, identifier } = searchHWR;
showToast({
critical: false,
kind: 'error',
description: t('errorSyncMsg', `Failed to sync the account with ${identifier}. and ${err}`),
description: t('errorSyncMsg', `Failed to sync the account with ${searchHWR.identifier}. ${err}`),
title: t('hwrERROR', 'Sync Failed'),
onActionButtonClick: () => close,
});
} finally {
setSyncLoading(false);
Expand Down
Loading

0 comments on commit a93b96f

Please sign in to comment.