diff --git a/packages/esm-billing-app/src/benefits-package/benefits-package.mock.ts b/packages/esm-billing-app/src/benefits-package/benefits-package.mock.ts index a1c59b684..15e7cc376 100644 --- a/packages/esm-billing-app/src/benefits-package/benefits-package.mock.ts +++ b/packages/esm-billing-app/src/benefits-package/benefits-package.mock.ts @@ -4,7 +4,7 @@ import { Diagnosis, Package, PatientBenefit, - SHAIntervension, + SHAIntervention, shifIdentifiersResponse, } from '../types'; @@ -52,10 +52,10 @@ export const packages = [ }, ] as Array; -export const intervensions = patientBenefits.map(({ interventionCode, interventionName }) => ({ +export const interventions = patientBenefits.map(({ interventionCode, interventionName }) => ({ interventionCode, interventionName, -})) as Array; +})) as Array; export const coverageEligibilityResponse = [ { diff --git a/packages/esm-billing-app/src/benefits-package/forms/benefit-pre-auth-form.workspace.tsx b/packages/esm-billing-app/src/benefits-package/forms/benefit-pre-auth-form.workspace.tsx index edf169c07..e03f3f6ad 100644 --- a/packages/esm-billing-app/src/benefits-package/forms/benefit-pre-auth-form.workspace.tsx +++ b/packages/esm-billing-app/src/benefits-package/forms/benefit-pre-auth-form.workspace.tsx @@ -28,7 +28,7 @@ import useProvider from '../../hooks/useProvider'; import { PatientBenefit } from '../../types'; import { preAuthenticateBenefit, preauthSchema } from '../benefits-package.resources'; import styles from './benefits-pre-auth-form.scss'; -import PackageIntervensions from './package-intervensions.component'; +import PackageInterventions from './package-interventions.component'; import { ErrorState } from '@openmrs/esm-patient-common-lib'; type BenefitsPreAuth = z.infer; @@ -240,8 +240,9 @@ const BenefitPreAuthForm: React.FC = ({ closeWorkspace, {selectedPackageObservable && ( - package_.uuid === selectedPackageObservable)?.packageCode ?? ''} + patientUuid={patientUuid} /> )} @@ -255,7 +256,7 @@ const BenefitPreAuthForm: React.FC = ({ closeWorkspace, invalid={form.formState.errors[field.name]?.message} invalidText={form.formState.errors[field.name]?.message} id="diagnoses" - titleText={t('diagnosis', 'Diagnosis')} + titleText={t('finalDiagnosis', 'Final Diagnosis')} selectedItems={field.value} label="Choose option" items={diagnoses.map((r) => r.id)} @@ -279,7 +280,7 @@ const BenefitPreAuthForm: React.FC = ({ closeWorkspace, - - - )} - -
- - - {inforce ? t('active', 'Active') : t('inactive', 'Inactive')} - -
+ if (isRegisteredOnSHA) { + return ( + +
+
+ {t('insurer', 'Insurer:')}{' '} + SHA + {isActive && ( + + + + )} +
+
+ + + {isActive ? t('active', 'Active') : t('inactive', 'Inactive')} +
- ); - })} - - ); +
+ + ); + } }; export default SHANumberValidity; diff --git a/packages/esm-billing-app/src/claims/dashboard/form/claims-form.component.tsx b/packages/esm-billing-app/src/claims/dashboard/form/claims-form.component.tsx index 326f1a8cf..b8cbc38d3 100644 --- a/packages/esm-billing-app/src/claims/dashboard/form/claims-form.component.tsx +++ b/packages/esm-billing-app/src/claims/dashboard/form/claims-form.component.tsx @@ -21,7 +21,7 @@ import { Controller, FormProvider, useForm } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; import { useParams } from 'react-router-dom'; import { z } from 'zod'; -import PackageIntervensions from '../../../benefits-package/forms/package-intervensions.component'; +import PackageInterventions from '../../../benefits-package/forms/package-interventions.component'; import { formatDate } from '../../../helpers/functions'; import { useSystemSetting } from '../../../hooks/getMflCode'; import usePackages from '../../../hooks/usePackages'; @@ -314,8 +314,9 @@ const ClaimsForm: React.FC = ({ bill, selectedLineItems }) => { {selectedPackageObservable && ( - package_.uuid === selectedPackageObservable)?.packageCode ?? ''} + patientUuid={patientUuid} /> diff --git a/packages/esm-billing-app/src/claims/pre-auth/form/pre-auth-form.component.tsx b/packages/esm-billing-app/src/claims/pre-auth/form/pre-auth-form.component.tsx deleted file mode 100644 index 9b373c312..000000000 --- a/packages/esm-billing-app/src/claims/pre-auth/form/pre-auth-form.component.tsx +++ /dev/null @@ -1,364 +0,0 @@ -import React, { useEffect, useMemo, useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import { - Column, - TextArea, - Form, - Layer, - Stack, - TextInput, - Row, - Button, - ButtonSet, - MultiSelect, - Tag, - InlineLoading, -} from '@carbon/react'; -import { navigate, showSnackbar } from '@openmrs/esm-framework'; -import { useSystemSetting } from '../../../hooks/getMflCode'; -import { useParams } from 'react-router-dom'; -import { useForm, Controller } from 'react-hook-form'; -import { z } from 'zod'; -import { zodResolver } from '@hookform/resolvers/zod'; -import { useVisit } from '../../dashboard/form/claims-form.resource'; -import styles from './pre-auth-form.scss'; -import { LineItem, MappedBill } from '../../../types'; -import { useInterventions, usePackages } from './pre-auth-form.resource'; -import { Service } from '../../../../../esm-lab-manifest-app/src/metrics/lab-manifest-metrics.component'; - -type PreAuthFormProps = { - bill: MappedBill; - selectedLineItems: LineItem[]; -}; - -const PreAuthFormSchema = z.object({ - claimCode: z.string().nonempty({ message: 'Claim code is required' }), - guaranteeId: z.string().nonempty({ message: 'Guarantee Id is required' }), - preAuthJustification: z.string().nonempty({ message: 'Claim justification is required' }), - diagnoses: z - .array( - z.object({ - id: z.string(), - text: z.string(), - }), - ) - .nonempty({ message: 'At least one diagnosis is required' }), - visitType: z.string().nonempty({ message: 'Visit type is required' }), - facility: z.string().nonempty({ message: 'Facility is required' }), - packages: z.array(z.string()).nonempty({ message: 'At least one package is required' }), - interventions: z.array(z.string()).nonempty({ message: 'At least one intervention is required' }), -}); - -const PreAuthForm: React.FC = ({ bill, selectedLineItems }) => { - const { t } = useTranslation(); - const { mflCodeValue } = useSystemSetting('facility.mflcode'); - const { patientUuid, billUuid } = useParams(); - const { visits: recentVisit } = useVisit(patientUuid); - const { interventions } = useInterventions(); - const { packages } = usePackages(); - - const [loading, setLoading] = useState(false); - - const handleNavigateToBillingOptions = () => - navigate({ - to: window.getOpenmrsSpaBase() + `home/billing/patient/${patientUuid}/${billUuid}`, - }); - - const diagnoses = useMemo(() => { - return ( - recentVisit?.encounters?.flatMap( - (encounter) => - encounter.diagnoses.map((diagnosis) => ({ - id: diagnosis.diagnosis.coded.uuid, - text: diagnosis.display, - certainty: diagnosis.certainty, - })) || [], - ) || [] - ); - }, [recentVisit]); - - const confirmedDiagnoses = useMemo(() => { - return diagnoses.filter((diagnosis) => diagnosis.certainty === 'CONFIRMED'); - }, [diagnoses]); - - const { - control, - handleSubmit, - formState: { errors, isValid }, - setValue, - reset, - } = useForm({ - mode: 'all', - resolver: zodResolver(PreAuthFormSchema), - defaultValues: { - claimCode: '', - guaranteeId: '', - preAuthJustification: '', - diagnoses: [], - visitType: '', - facility: '', - packages: [], - interventions: [], - }, - }); - - const onSubmit = async (data) => { - setLoading(true); - try { - showSnackbar({ - kind: 'success', - title: t('requestPreAuth', 'Pre Authorization'), - subtitle: t('sendClaim', 'Pre authorization request sent successfully'), - timeoutInMs: 3000, - isLowContrast: true, - }); - reset(); - setTimeout(() => { - navigate({ - to: window.getOpenmrsSpaBase() + `home/billing/`, - }); - }, 2000); - } catch (err) { - console.error(err); - showSnackbar({ - kind: 'error', - title: t('requestPreAuthError', 'Pre Authorization Error'), - subtitle: t('sendClaimError', 'Pre authorization request failed, please try later'), - timeoutInMs: 2500, - isLowContrast: true, - }); - } finally { - setLoading(false); - } - }; - - useEffect(() => { - reset({ - diagnoses: confirmedDiagnoses, - visitType: recentVisit?.visitType?.display || '', - facility: `${recentVisit?.location?.display || ''} - ${mflCodeValue || ''}`, - claimCode: '', - guaranteeId: '', - preAuthJustification: '', - packages: [], - interventions: [], - }); - }, [confirmedDiagnoses, recentVisit, mflCodeValue, reset]); - - return ( -
- - {t('formTitle', 'Fill in the form details')} - - - ( -