From 634b8420fc19487a84ea0998ad84a70223195b1b Mon Sep 17 00:00:00 2001 From: Laurent Ouma Date: Tue, 3 Dec 2024 21:25:51 +0300 Subject: [PATCH] mocked fetch of interventions and packages from api --- .../src/hooks/benefits.mock.ts | 391 ++++++++++++++++++ .../src/hooks/useInterventions.ts | 10 +- .../esm-billing-app/src/hooks/usePackages.ts | 12 +- 3 files changed, 408 insertions(+), 5 deletions(-) create mode 100644 packages/esm-billing-app/src/hooks/benefits.mock.ts diff --git a/packages/esm-billing-app/src/hooks/benefits.mock.ts b/packages/esm-billing-app/src/hooks/benefits.mock.ts new file mode 100644 index 000000000..44182acfb --- /dev/null +++ b/packages/esm-billing-app/src/hooks/benefits.mock.ts @@ -0,0 +1,391 @@ +export const category = [ + { + id: 1, + code: 'SHA-01', + categoryName: 'Ambulance and Emergency Services', + }, + { + id: 2, + code: 'SHA-02', + categoryName: 'Assistive Devices', + }, + { + id: 3, + code: 'SHA-03', + categoryName: 'Critical Care Services', + }, + { + id: 4, + code: 'SHA-04', + categoryName: 'End of Life services', + }, + { + id: 5, + code: 'SHA-05', + categoryName: 'Optical Health Services', + }, + { + id: 6, + code: 'SHA-06', + categoryName: 'Hematology and Oncology Services', + }, + { + id: 7, + code: 'SHA-07', + categoryName: 'Inpatient Services', + }, + { + id: 8, + code: 'SHA-08', + categoryName: 'Maternity and Child Health Services', + }, + { + id: 9, + code: 'SHA-09', + categoryName: 'Medical Imaging & Other Investigations ', + }, + { + id: 10, + code: 'SHA-10', + categoryName: 'Mental Wellness Services', + }, + { + id: 11, + code: 'SHA-11', + categoryName: 'Oral Health Services', + }, + { + id: 12, + code: 'SHA-12', + categoryName: 'Outpatient Services', + }, + { + id: 13, + code: 'SHA-13', + categoryName: 'Palliative Care services', + }, + { + id: 14, + code: 'SHA-14', + categoryName: 'Pharmacy Services', + }, + { + id: 15, + code: 'SHA-15', + categoryName: 'Rehabilation Services', + }, + { + id: 16, + code: 'SHA-16', + categoryName: 'Renal Care Services', + }, + { + id: 17, + code: 'SHA-17', + categoryName: 'Screening', + }, + { + id: 18, + code: 'SHA-18', + categoryName: 'Essential Diagnostic Laboratory listing for NCDs', + }, + { + id: 19, + code: 'SHA-19', + categoryName: 'Surgical Services', + }, + { + id: 20, + code: 'SHA-20', + categoryName: 'Overseas treatment', + }, +]; + +export const interventions = [ + { + interventionCode: 'SHA-01-001', + shaCategory: 'Ambulance & Emergency services', + accessCode: 'outpatient', + subCategoryBenefitsPackage: 'Evacuations', + interventionName: 'Ambulance services (Intra-metro within 25KM radius )', + needsPreAuth: 'NO', + categoryHealthFacility: 'Outsourced', + providerPaymentMechanism: 'FFS', + gender: '', + limitIndividualHousehold: 'None', + interventionQuantityYear: 'LIMITLESS', + tariffs: '', + limitIndividual: '', + minAge: '', + maxAge: '', + limitsIndividualHousehold: '', + phc: '0%', + shif: '0%', + eccif: '0%', + automateManual: 'N/A', + }, + { + interventionCode: 'SHA-01-002', + shaCategory: 'Ambulance & Emergency services', + accessCode: '', + subCategoryBenefitsPackage: 'Evacuations', + interventionName: 'Ambulance services (Extra-metro,beyond 25KM )', + needsPreAuth: 'NO', + categoryHealthFacility: 'Outsourced', + providerPaymentMechanism: 'FFS', + gender: '', + limitIndividualHousehold: 'None', + interventionQuantityYear: 'LIMITLESS', + tariffs: '', + limitIndividual: '', + minAge: '', + maxAge: '', + limitsIndividualHousehold: '', + phc: '0%', + shif: '0%', + eccif: '0%', + automateManual: 'N/A', + }, + { + interventionCode: 'SHA-01-003', + shaCategory: 'Ambulance & Emergency services', + accessCode: 'inpatient', + subCategoryBenefitsPackage: 'Emergency Room Services', + interventionName: 'Emergency room services', + needsPreAuth: 'YES', + categoryHealthFacility: 'In-network', + providerPaymentMechanism: 'Capitation', + gender: '', + limitIndividualHousehold: 'Individual', + interventionQuantityYear: '1', + tariffs: '10000', + limitIndividual: '10000', + minAge: '18', + maxAge: '65', + limitsIndividualHousehold: '10000', + phc: '20%', + shif: '80%', + eccif: '0%', + automateManual: 'AUTOMATE', + }, + { + interventionCode: 'SHA-16-005', + shaCategory: 'Renal Care Package', + accessCode: '', + subCategoryBenefitsPackage: 'Renal Care package', + interventionName: 'Insertion of Continuous Ambulatory Peritoneal Dialysis (CAPD) catheter', + needsPreAuth: 'YES', + categoryHealthFacility: '', + providerPaymentMechanism: '', + gender: '', + limitIndividualHousehold: '', + interventionQuantityYear: '', + tariffs: '33600', + limitIndividual: '', + minAge: '', + maxAge: '', + limitsIndividualHousehold: 'Individual', + phc: '0%', + shif: '100%', + eccif: '0%', + automateManual: 'AUTOMATE', + }, + { + interventionCode: 'SHA-02-003', + shaCategory: 'Assistive Devices', + accessCode: 'outpatient', + subCategoryBenefitsPackage: 'Prosthetics', + interventionName: 'Prosthetic limbs', + needsPreAuth: 'YES', + categoryHealthFacility: 'In-network', + providerPaymentMechanism: 'Capitation', + gender: '', + limitIndividualHousehold: 'Individual', + interventionQuantityYear: '1', + tariffs: '5000', + limitIndividual: '5000', + minAge: '18', + maxAge: '65', + limitsIndividualHousehold: '5000', + phc: '20%', + shif: '80%', + eccif: '0%', + automateManual: 'AUTOMATE', + }, + { + interventionCode: 'SHA-02-004', + shaCategory: 'Assistive Devices', + accessCode: 'inpatient', + subCategoryBenefitsPackage: 'Orthotics', + interventionName: 'Orthotic devices', + needsPreAuth: 'YES', + categoryHealthFacility: 'In-network', + providerPaymentMechanism: 'Capitation', + gender: '', + limitIndividualHousehold: 'Individual', + interventionQuantityYear: '1', + tariffs: '3000', + limitIndividual: '3000', + minAge: '18', + maxAge: '65', + limitsIndividualHousehold: '3000', + phc: '20%', + shif: '80%', + eccif: '0%', + automateManual: 'AUTOMATE', + }, + { + interventionCode: 'SHA-02-005', + shaCategory: 'Assistive Devices', + accessCode: 'outpatient', + subCategoryBenefitsPackage: 'Wheelchairs', + interventionName: 'Wheelchairs', + needsPreAuth: 'NO', + categoryHealthFacility: 'Outsourced', + providerPaymentMechanism: 'FFS', + gender: '', + limitIndividualHousehold: 'None', + interventionQuantityYear: 'LIMITLESS', + tariffs: '', + limitIndividual: '', + minAge: '', + maxAge: '', + limitsIndividualHousehold: '', + phc: '0%', + shif: '0%', + eccif: '0%', + automateManual: 'N/A', + }, + { + interventionCode: 'SHA-03-004', + shaCategory: 'Critical Care Services', + accessCode: 'inpatient', + subCategoryBenefitsPackage: 'ICU Care', + interventionName: 'ICU care for critical patients', + needsPreAuth: 'YES', + categoryHealthFacility: 'In-network', + providerPaymentMechanism: 'Capitation', + gender: '', + limitIndividualHousehold: 'Individual', + interventionQuantityYear: '1', + tariffs: '10000', + limitIndividual: '10000', + minAge: '18', + maxAge: '65', + limitsIndividualHousehold: '10000', + phc: '20%', + shif: '80%', + eccif: '0%', + automateManual: 'AUTOMATE', + }, + { + interventionCode: 'SHA-03-005', + shaCategory: 'Critical Care Services', + accessCode: 'inpatient', + subCategoryBenefitsPackage: 'CCU Care', + interventionName: 'CCU care for critical patients', + needsPreAuth: 'YES', + categoryHealthFacility: 'In-network', + providerPaymentMechanism: 'Capitation', + gender: '', + limitIndividualHousehold: 'Individual', + interventionQuantityYear: '1', + tariffs: '8000', + limitIndividual: '8000', + minAge: '18', + maxAge: '65', + limitsIndividualHousehold: '8000', + phc: '20%', + shif: '80%', + eccif: '0%', + automateManual: 'AUTOMATE', + }, + { + interventionCode: 'SHA-03-006', + shaCategory: 'Critical Care Services', + accessCode: 'outpatient', + subCategoryBenefitsPackage: 'Emergency Response', + interventionName: 'Emergency response services', + needsPreAuth: 'NO', + categoryHealthFacility: 'Outsourced', + providerPaymentMechanism: 'FFS', + gender: '', + limitIndividualHousehold: 'None', + interventionQuantityYear: 'LIMITLESS', + tariffs: '', + limitIndividual: '', + minAge: '', + maxAge: '', + limitsIndividualHousehold: '', + phc: '0%', + shif: '0%', + eccif: '0%', + automateManual: 'N/A', + }, + { + interventionCode: 'SHA-04-005', + shaCategory: 'End of Life services', + accessCode: 'outpatient', + subCategoryBenefitsPackage: 'Palliative Care', + interventionName: 'Palliative care services', + needsPreAuth: 'NO', + categoryHealthFacility: 'Outsourced', + providerPaymentMechanism: 'FFS', + gender: '', + limitIndividualHousehold: 'None', + interventionQuantityYear: 'LIMITLESS', + tariffs: '', + limitIndividual: '', + minAge: '', + maxAge: '', + limitsIndividualHousehold: '', + phc: '0%', + shif: '0%', + eccif: '0%', + automateManual: 'N/A', + }, + { + interventionCode: 'SHA-04-006', + shaCategory: 'End of Life services', + accessCode: 'inpatient', + subCategoryBenefitsPackage: 'Hospice Care', + interventionName: 'Hospice care services', + needsPreAuth: 'YES', + categoryHealthFacility: 'In-network', + providerPaymentMechanism: 'Capitation', + gender: '', + limitIndividualHousehold: 'Individual', + interventionQuantityYear: '1', + tariffs: '6000', + limitIndividual: '6000', + minAge: '18', + maxAge: '65', + limitsIndividualHousehold: '6000', + phc: '20%', + shif: '80%', + eccif: '0%', + automateManual: 'AUTOMATE', + }, + { + interventionCode: 'SHA-04-007', + shaCategory: 'End of Life services', + accessCode: 'outpatient', + subCategoryBenefitsPackage: 'Bereavement Support', + interventionName: 'Bereavement support services', + needsPreAuth: 'NO', + categoryHealthFacility: 'Outsourced', + providerPaymentMechanism: 'FFS', + gender: '', + limitIndividualHousehold: 'None', + interventionQuantityYear: 'LIMITLESS', + tariffs: '', + limitIndividual: '', + minAge: '', + maxAge: '', + limitsIndividualHousehold: '', + phc: '0%', + shif: '0%', + eccif: '0%', + automateManual: 'N/A', + }, +]; diff --git a/packages/esm-billing-app/src/hooks/useInterventions.ts b/packages/esm-billing-app/src/hooks/useInterventions.ts index 80958d40d..6ec2383ed 100644 --- a/packages/esm-billing-app/src/hooks/useInterventions.ts +++ b/packages/esm-billing-app/src/hooks/useInterventions.ts @@ -2,15 +2,21 @@ import { FetchResponse, openmrsFetch, useConfig } from '@openmrs/esm-framework'; import useSWR from 'swr'; import { BillingConfig } from '../config-schema'; import { SHAIntervension } from '../types'; +import { interventions } from './benefits.mock'; export const useInterventions = (code: string) => { const { hieBaseUrl } = useConfig(); const url = `${hieBaseUrl}/master/benefit-master/code?searchKey=${code}`; - const { isLoading, error, data } = useSWR>>(url, openmrsFetch); + const { isLoading, error, data } = useSWR>(url, async (key) => { + await new Promise((resolve, reject) => { + setTimeout(resolve, 2000); + }); + return interventions?.filter((inter) => inter.interventionCode.includes(code)); + }); return { isLoading, - interventions: data?.data ?? [], + interventions: data ?? [], error, }; }; diff --git a/packages/esm-billing-app/src/hooks/usePackages.ts b/packages/esm-billing-app/src/hooks/usePackages.ts index edcf476ff..579bb1b9d 100644 --- a/packages/esm-billing-app/src/hooks/usePackages.ts +++ b/packages/esm-billing-app/src/hooks/usePackages.ts @@ -2,6 +2,7 @@ import { FetchResponse, openmrsFetch, useConfig } from '@openmrs/esm-framework'; import useSWR from 'swr'; import { BillingConfig } from '../config-schema'; import { Package } from '../types'; +import { category } from './benefits.mock'; /** * Hook that return a list of sha benefits category/packages @@ -11,14 +12,19 @@ const usePackages = () => { const { hieBaseUrl } = useConfig(); const url = `${hieBaseUrl}/master/category/all-`; - const { data, isLoading, error } = useSWR>>( + const { data, isLoading, error } = useSWR>( url, - openmrsFetch, + async () => { + await new Promise((resolve, reject) => { + setTimeout(resolve, 2000); + }); + return category; + }, ); return { isLoading, - packages: (data?.data ?? []).map( + packages: (data ?? []).map( (category) => ({ uuid: `${category.id}`,