diff --git a/packages/esm-cervical-cancer-app/src/config-schema.ts b/packages/esm-cervical-cancer-app/src/config-schema.ts new file mode 100644 index 000000000..c4a3612b7 --- /dev/null +++ b/packages/esm-cervical-cancer-app/src/config-schema.ts @@ -0,0 +1,43 @@ +import { Type } from '@openmrs/esm-framework'; + +export const configSchema = { + encounterTypes: { + _type: Type.Object, + _description: 'Encounter type UUIDs for Cacx.', + _default: { + cacxRegistrationEncounterType_UUID: '3eb24129-9f7d-4372-a14e-c2cf577e5db1', + cacxTreatmentEncounterType_UUID: '60c80941-c3dc-45c6-9b78-c150e0470cbd', + }, + }, + obsConcepts: { + _type: Type.Object, + _description: 'List of observation concept UUIDs related to Cacx.', + _default: { + cervicalCancerScreeningDateConcept: '2f256b46-395b-40f8-b93e-3ea68e5531bc', + previouslyScreenedConcept: '7cf4c96a-3e68-4ca5-9b49-9148adc6263d', + eligibleForScreeningConcept: 'b77ef6d3-4895-4e88-8b17-fa4aff6eba59', + cacxEncounterDateConcept: '163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', + screeningMethodConcept: '53ff5cd0-0f37-4190-87b1-9eb439a15e94', + cacxTreatmentConcept: '3a8bb4b4-7496-415d-a327-57ae3711d4eb', + colopsyResultsConcept: '9096a18e-c009-4f4c-b0ba-0605e0f16578', + humanPapilomaVirusResultsConcept: '159859AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', + papanicolaouSmearResultsConcept: '28bab50e-7ff7-4216-81be-3f7ad05c6547', + VIAProcedureResultsConcept: 'cc647244-0826-4d8e-8c5a-d7a371267bf4', + }, + }, + formNames: { + _type: Type.Object, + _description: 'List of forms related to Cacx.', + _default: { + screeningAndCancerTreatmentForm: 'Screening and Cancer Treatment Form', + cervicalCancerRegistrationForm: 'Cervical Cancer Registration Form', + }, + }, +}; + +export interface ConfigObject { + identifiers: Object; + encounterTypes: Object; + obsConcepts: Object; + formNames: Object; +} diff --git a/packages/esm-cervical-cancer-app/src/constants.ts b/packages/esm-cervical-cancer-app/src/constants.ts deleted file mode 100644 index 440626deb..000000000 --- a/packages/esm-cervical-cancer-app/src/constants.ts +++ /dev/null @@ -1,15 +0,0 @@ -//cacx registration -export const cacxRegistrationEncounterType_UUID = '3eb24129-9f7d-4372-a14e-c2cf577e5db1'; -export const cervicalCancerScreeningDateConcept = '2f256b46-395b-40f8-b93e-3ea68e5531bc'; -export const previouslyScreenedConcept = '7cf4c96a-3e68-4ca5-9b49-9148adc6263d'; -export const eligibleForScreeningConcept = 'b77ef6d3-4895-4e88-8b17-fa4aff6eba59'; - -//cacx treatment -export const cacxTreatmentEncounterType_UUID = '60c80941-c3dc-45c6-9b78-c150e0470cbd'; -export const cacxEncounterDateConcept = '163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; -export const screeningMethodConcept = '53ff5cd0-0f37-4190-87b1-9eb439a15e94'; -export const cacxTreatmentConcept = '3a8bb4b4-7496-415d-a327-57ae3711d4eb'; -export const colopsyResultsConcept = '9096a18e-c009-4f4c-b0ba-0605e0f16578'; -export const humanPapilomaVirusResultsConcept = '159859AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; -export const papanicolaouSmearResultsConcept = '28bab50e-7ff7-4216-81be-3f7ad05c6547'; -export const VIAProcedureResultsConcept = 'cc647244-0826-4d8e-8c5a-d7a371267bf4'; diff --git a/packages/esm-cervical-cancer-app/src/index.ts b/packages/esm-cervical-cancer-app/src/index.ts index 4a3d590ba..a141723fd 100644 --- a/packages/esm-cervical-cancer-app/src/index.ts +++ b/packages/esm-cervical-cancer-app/src/index.ts @@ -3,6 +3,7 @@ import { caCxSummaryDashboardMeta, caCxVisitsDashboardMeta, cervicalCancerFolder import { createDashboardGroup, createDashboardLink } from '@openmrs/esm-patient-common-lib'; import CacxSummaryList from './views/cacx-summary/cacx-summary.component'; import CacxVisitServices from './views/cacx-visits/cacx-visits-services.component'; +import { configSchema } from './config-schema'; export const importTranslation = require.context('../translations', false, /.json$/, 'lazy'); @@ -16,7 +17,7 @@ const options = { }; export function startupApp() { - defineConfigSchema(moduleName, {}); + defineConfigSchema(moduleName, configSchema); } export const cacxPatientChartDashboard = getSyncLifecycle(createDashboardGroup(cervicalCancerFolderMeta), options); diff --git a/packages/esm-cervical-cancer-app/src/views/cacx-visits/tabs/cacx-registration.component.tsx b/packages/esm-cervical-cancer-app/src/views/cacx-visits/tabs/cacx-registration.component.tsx index 00ed2c93c..a471915c0 100644 --- a/packages/esm-cervical-cancer-app/src/views/cacx-visits/tabs/cacx-registration.component.tsx +++ b/packages/esm-cervical-cancer-app/src/views/cacx-visits/tabs/cacx-registration.component.tsx @@ -1,13 +1,8 @@ import React, { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { EncounterList, EncounterListColumn, getObsFromEncounter } from '@ohri/openmrs-esm-ohri-commons-lib'; -import { - cacxRegistrationEncounterType_UUID, - cervicalCancerScreeningDateConcept, - eligibleForScreeningConcept, - previouslyScreenedConcept, -} from '../../../constants'; import { moduleName } from '../../../index'; +import { useConfig } from '@openmrs/esm-framework'; interface CacxRegistrationProps { patientUuid: string; @@ -16,6 +11,15 @@ interface CacxRegistrationProps { export const CacxRegistration: React.FC = ({ patientUuid }) => { const { t } = useTranslation(); + const config = useConfig(); + + const { cervicalCancerScreeningDateConcept, eligibleForScreeningConcept, previouslyScreenedConcept } = + config.obsConcepts; + + const { cacxRegistrationEncounterType_UUID } = config.encounterTypes; + + const { cervicalCancerRegistrationForm } = config.formNames; + const columnsLab: EncounterListColumn[] = useMemo( () => [ { @@ -46,14 +50,14 @@ export const CacxRegistration: React.FC = ({ patientUuid getValue: (encounter) => { const baseActions = [ { - form: { name: 'Cervical Cancer Registration Form', package: 'cacx' }, + form: { name: cervicalCancerRegistrationForm, package: 'cacx' }, encounterUuid: encounter.uuid, intent: '*', label: t('viewDetails', 'View Details'), mode: 'view', }, { - form: { name: 'Cervical Cancer Registration Form', package: 'cacx' }, + form: { name: cervicalCancerRegistrationForm, package: 'cacx' }, encounterUuid: encounter.uuid, intent: '*', label: t('editForm', 'Edit Form'), @@ -73,7 +77,7 @@ export const CacxRegistration: React.FC = ({ patientUuid = ({ patientUuid }) => { const { t } = useTranslation(); + const config = useConfig(); + + const { + cacxEncounterDateConcept, + screeningMethodConcept, + cacxTreatmentConcept, + colopsyResultsConcept, + humanPapilomaVirusResultsConcept, + papanicolaouSmearResultsConcept, + VIAProcedureResultsConcept, + } = config.obsConcepts; + + const { cacxTreatmentEncounterType_UUID } = config.encounterTypes; + + const { screeningAndCancerTreatmentForm } = config.formNames; const columnsLab: EncounterListColumn[] = useMemo( () => [ @@ -67,14 +73,14 @@ export const CacxTreatment: React.FC = ({ patientUuid }) => getValue: (encounter) => { const baseActions = [ { - form: { name: 'Screening and Cancer Treatment Form', package: 'cacx' }, + form: { name: screeningAndCancerTreatmentForm, package: 'cacx' }, encounterUuid: encounter.uuid, intent: '*', label: t('viewDetails', 'View Details'), mode: 'view', }, { - form: { name: 'Screening and Cancer Treatment Form', package: 'cacx' }, + form: { name: screeningAndCancerTreatmentForm, package: 'cacx' }, encounterUuid: encounter.uuid, intent: '*', label: t('editForm', 'Edit Form'), @@ -94,7 +100,7 @@ export const CacxTreatment: React.FC = ({ patientUuid }) =>