From 46965951e505ba92bca60a849dd8fc027fcbd88c Mon Sep 17 00:00:00 2001 From: hadijahkyampeire Date: Tue, 11 Jun 2024 16:27:46 +0300 Subject: [PATCH 1/4] use config keys in our json(hct) --- .../utils/encounter-list-config-builder.ts | 60 ++++++- .../src/utils/encounter-list-utils.ts | 16 +- .../src/config-schema.ts | 7 + .../general-conselling-config.json | 56 +++---- .../general-counselling-summary.component.tsx | 3 +- ...artner-notification-services.component.tsx | 3 +- .../patner-notification-config.json | 42 ++--- .../program-management-config.json | 149 +++++++++--------- .../program-management-summary.component.tsx | 4 +- .../views/visits/clinical-visit-config.json | 18 +-- .../views/visits/visits-summary.component.tsx | 3 +- 11 files changed, 219 insertions(+), 142 deletions(-) diff --git a/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts b/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts index bb69d6329..fcbfb32df 100644 --- a/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts +++ b/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts @@ -6,6 +6,16 @@ import { } from './encounter-list-utils'; import { renderTag } from './encounter-list-component-util'; +interface ConfigSchema { + [key: string]: { + _type: unknown; + _description: string; + _default: { + [key: string]: string; + }; + }; +} + interface MenuProps { menuId: string; tabDefinitions: Array; @@ -142,8 +152,54 @@ export const getTabColumns = (columnsDefinition: Array) => { return columns; }; -export const getMenuItemTabConfiguration = (schemaConfig: MenuProps) => { - const tabs = schemaConfig.tabDefinitions.map((tab) => { +function extractDefaults(schema) { + const result = {}; + + function traverse(schema) { + for (const key in schema) { + if (key === '_default') { + Object.assign(result, schema[key]); + } else if (typeof schema[key] === 'object' && !Array.isArray(schema[key])) { + traverse(schema[key]); + } + } + } + + traverse(schema); + return result; +} + +function replaceWithConfigDefaults(obj, configDefaults) { + if (Array.isArray(obj)) { + return obj.map((item) => { + if (typeof item === 'string' && configDefaults.hasOwnProperty(item)) { + return configDefaults[item]; + } else { + return replaceWithConfigDefaults(item, configDefaults); + } + }); + } else if (typeof obj === 'object' && obj !== null) { + const newObj = {}; + for (const key in obj) { + if (typeof obj[key] === 'string' && configDefaults.hasOwnProperty(obj[key])) { + newObj[key] = configDefaults[obj[key]]; + } else { + newObj[key] = replaceWithConfigDefaults(obj[key], configDefaults); + } + } + return newObj; + } else { + return obj; + } +} + +export const getMenuItemTabConfiguration = (schemaConfig: MenuProps, configSchema?: ConfigSchema) => { + // gonna make the configSchema optional for now until we implement it everywher + const configDefaults = extractDefaults(configSchema); + + const transformedSchemaConfig = replaceWithConfigDefaults(schemaConfig, configDefaults); + + const tabs = (configSchema ? transformedSchemaConfig.tabDefinitions : schemaConfig.tabDefinitions).map((tab) => { return { name: tab.tabName, hasFilter: tab.hasFilter || false, diff --git a/packages/esm-commons-lib/src/utils/encounter-list-utils.ts b/packages/esm-commons-lib/src/utils/encounter-list-utils.ts index 448591810..a844321b6 100644 --- a/packages/esm-commons-lib/src/utils/encounter-list-utils.ts +++ b/packages/esm-commons-lib/src/utils/encounter-list-utils.ts @@ -31,7 +31,12 @@ export function getObsFromEncounters(encounters, obsConcept) { export function resolveValueUsingMappings(encounter, concept, mappings) { const obs = findObs(encounter, concept); - return obs ? mappings[obs.value.uuid] || obs.value : '--'; + for (const key in mappings) { + if (mappings[key] === obs.value.uuid) { + return key; + } + } + return '--'; } export function getConceptFromMappings(encounter, concepts) { @@ -77,10 +82,15 @@ export function getObsFromEncounter( let obs = findObs(encounter, obsConcept); if (isTrueFalseConcept) { - if (obs?.value?.uuid == 'cf82933b-3f3f-45e7-a5ab-5d31aaee3da3') { + if ( + (obs?.value?.uuid != 'cf82933b-3f3f-45e7-a5ab-5d31aaee3da3' && obs?.value?.name?.name !== 'Unknown') || + obs?.value?.name?.name === 'FALSE' + ) { + return 'No'; + } else if (obs?.value?.uuid == 'cf82933b-3f3f-45e7-a5ab-5d31aaee3da3') { return 'Yes'; } else { - return 'No'; + return obs?.value?.name?.name; } } diff --git a/packages/esm-hiv-care-treatment-app/src/config-schema.ts b/packages/esm-hiv-care-treatment-app/src/config-schema.ts index fcc648714..3d28834b5 100644 --- a/packages/esm-hiv-care-treatment-app/src/config-schema.ts +++ b/packages/esm-hiv-care-treatment-app/src/config-schema.ts @@ -95,6 +95,13 @@ export const configSchema = { computedHIV_StatusConcept: 'a5261998-c635-4e27-870c-e837faf6cf9a', linkedToCareCodeConcept: 'e8e8fe71-adbb-48e7-b531-589985094d30', linkedToCareYesValueConcept: '1065AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', + startART: '1256AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', + substituteART: '1258AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', + switchART: '1259AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', + stopART: '1260AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', + restartART: '3e69cb60-2943-410f-83d4-b359ae83fefd', + hivGrayStatus: '664AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', + hivPurpleStatus: '1067AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', }, }, cohorts: { diff --git a/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-conselling-config.json b/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-conselling-config.json index 6e73a72fd..ac65602b7 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-conselling-config.json +++ b/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-conselling-config.json @@ -5,46 +5,46 @@ "tabName": "Mental Health Assessment", "headerTitle": "Mental Health Assessment", "displayText": "Mental Health Assessment", - "encounterType": "36db5123-0ad5-41c0-9037-625b46e0ceef", + "encounterType": "MentalHealthAssessmentEncounter_UUID", "columns": [ { "id": "screeningDate", "isDate": true, "title": "Screening Date", - "concept": "160753AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "dateOfEventConcept" }, { "id": "littleInterest", "title": "Disinterested in Things", - "concept": "167006AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "LittleInterestConcept_UUID" }, { "id": "depressed", "title": "Depressed", - "concept": "167007AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "DepressionConcept_UUID" }, { "id": "appetite", "title": "Poor Appetite", - "concept": "167070AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "PoorAppetiteConcept_UUID" }, { "id": "concentration", "title": "Concentration Problems", - "concept": "167072AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "PoorConcentrationConcept_UUID" }, { "id": "actions", "title": "Actions", "actionOptions": [ { - "formName": "Mental Health Assessment Form", + "formName": "MentalHealthFormName", "package": "hiv-care-treatment", "label": "View Details", "mode": "view" }, { - "formName": "Mental Health Assessment Form", + "formName": "MentalHealthFormName", "package": "hiv-care-treatment", "label": "Edit Form", "mode": "edit" @@ -54,12 +54,12 @@ ], "launchOptions": { "displayText": "Add", - "moduleName": "@ohri/openmrs-esm-ohri-hiv-app" + "moduleName": "@ohri/openmrs-esm-ohri-hiv-care-treatment-app" }, "formList": [ { - "name": "Mental Health Assessment Form", - "uuid": "2069bd57-d534-3de9-ae24-f1d4e4b2de83" + "name": "MentalHealthFormName", + "uuid": "mentalHealthFormUuid" } ] }, @@ -67,44 +67,44 @@ "tabName": "Intimate Partner Violence", "headerTitle": "Intimate Partner Violence", "displayText": "Intimate Partner Violence", - "encounterType": "881fff34-b4a9-4d11-b2f5-a8a23a9f402b", + "encounterType": "IntimatePartnerEncounterType_UUID", "columns": [ { "id": "screeningDate", "isDate": true, "title": "Screening Date", - "concept": "160753AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "dateOfEventConcept" }, { "id": "physicalAbuse", "title": "Physical Abuse", "isTrueFalseConcept": true, - "concept": "2a228c6a-1575-43d7-9d42-9b68d0629f46" + "concept": "PhysicalAbuse_UUID" }, { "id": "emotionalAbuse", "title": "Emotional Abuse", "isTrueFalseConcept": true, - "concept": "bd86f7ee-1d5f-4f5d-aa0f-4680aa6e65cb" + "concept": "EmotionalAbuse_UUID" }, { "id": "sexualAbuse", "title": "Sexual Abuse", "isTrueFalseConcept": true, - "concept": "1246AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "SexualAbuse_UUID" }, { "id": "actions", "title": "Actions", "actionOptions": [ { - "formName": "Intimate Partner Violence Form", + "formName": "IntimatePartnerFormName", "package": "hiv-care-treatment", "label": "View Details", "mode": "view" }, { - "formName": "Intimate Partner Violence Form", + "formName": "IntimatePartnerFormName", "package": "hiv-care-treatment", "label": "Edit Forms", "mode": "edit" @@ -114,12 +114,12 @@ ], "launchOptions": { "displayText": "Add", - "moduleName": "@ohri/openmrs-esm-ohri-hiv-app" + "moduleName": "@ohri/openmrs-esm-ohri-hiv-care-treatment-app" }, "formList": [ { - "name": "Intimate Partner Violence Form", - "uuid": "f99fadd8-feb7-321c-ab58-7569805668e7" + "name": "IntimatePartnerFormName", + "uuid": "5c37314f-c558-3720-8780-d123c70f4e23" } ] }, @@ -127,31 +127,31 @@ "tabName": "Disclosure", "headerTitle": "Disclosure", "displayText": "Disclosure", - "encounterType": "390c2f21-c1c4-4246-94ca-a026157cd1db", + "encounterType": "PeadsDisclosureEncounterType_UUID", "columns": [ { "id": "disclosureDate", "isDate": true, "title": "Disclosure Date", - "concept": "85fbdcc8-8dbc-40a9-b85f-5d1bfe1ab63d" + "concept": "DisclosureDate_UUID" }, { "id": "disclosureStage", "title": "Disclosure Stage", - "concept": "573f93e2-12f6-483e-aa6e-14e9b76b311a" + "concept": "DisclosureStage_UUID" }, { "id": "actions", "title": "Actions", "actionOptions": [ { - "formName": "Age Appropriate Disclosure Form", + "formName": "DisclosureFormName", "package": "hiv", "label": "View Details", "mode": "view" }, { - "formName": "Age Appropriate Disclosure Form", + "formName": "DisclosureFormName", "package": "hiv", "label": "Edit Forms", "mode": "edit" @@ -165,8 +165,8 @@ }, "formList": [ { - "name": "Age Appropriate Disclosure Form", - "uuid": "cb30cea5-3166-3e88-befb-9141e5f3769d" + "name": "DisclosureFormName", + "uuid": "disclosureFormUuid" } ] } diff --git a/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-counselling-summary.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-counselling-summary.component.tsx index 7b3bab3a4..51ebf6bf8 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-counselling-summary.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-counselling-summary.component.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import generalConsellingConfigSchema from './general-conselling-config.json'; +import { configSchema } from '../../config-schema'; import styles from '../common.scss'; @@ -10,7 +11,7 @@ interface OverviewListProps { } const GeneralCounsellingSummary: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(generalConsellingConfigSchema); + const tabs = getMenuItemTabConfiguration(generalConsellingConfigSchema, configSchema); const tabFilter = (encounter, formName) => { return encounter?.form?.name === formName; diff --git a/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/partner-notification-services.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/partner-notification-services.component.tsx index dfec35de1..36beacd01 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/partner-notification-services.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/partner-notification-services.component.tsx @@ -7,6 +7,7 @@ import { findObs, } from '@ohri/openmrs-esm-ohri-commons-lib'; import partnerNotificationsConfigSchema from './patner-notification-config.json'; +import { configSchema } from '../../config-schema'; import styles from '../common.scss'; @@ -15,7 +16,7 @@ interface OverviewListProps { } const PartnerNotificationServices: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(partnerNotificationsConfigSchema); + const tabs = getMenuItemTabConfiguration(partnerNotificationsConfigSchema, configSchema); const tabFilter = (encounter, formName) => { return encounter?.form?.name === formName; diff --git a/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/patner-notification-config.json b/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/patner-notification-config.json index e75565c5d..77918b3a0 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/patner-notification-config.json +++ b/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/patner-notification-config.json @@ -6,33 +6,33 @@ "hasFilter": true, "headerTitle": "Partner Notification", "displayText": "Partner Notification", - "encounterType": "4dd0ee63-805f-43e9-833c-6386ba97fdc1", + "encounterType": "PatnerNotificationEncounterType_UUID", "columns": [ { "id": "contactDate", "isDate": true, "title": "Contact Date", - "concept": "160753AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "dateOfEventConcept" }, { "id": "name", "title": "Name", - "concept": "166102AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "FirstName_UUID" }, { "id": "relationship", "title": "Relationship", - "concept": "85d3b4fe-c1a9-4e27-a86b-dcc1e30c8a93" + "concept": "Relationship_UUID" }, { "id": "hivStatus", "title": "Status", - "concept": "1436AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "concept": "IndexHIVStatus_UUID", "type": "hivStatus", "statusColorMappings": { - "703AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "red", - "664AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "gray", - "1067AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "purple" + "finalPositiveHIVValueConcept": "red", + "hivGrayStatus": "gray", + "hivPurpleStatus": "purple" } }, { @@ -40,13 +40,13 @@ "title": "Actions", "actionOptions": [ { - "formName": "Partner Notification Form", + "formName": "PartnerNotificationFormName", "package": "hiv-care-treatment", "label": "View Details", "mode": "view" }, { - "formName": "Partner Notification Form", + "formName": "PartnerNotificationFormName", "package": "hiv-care-treatment", "label": "Edit Form", "mode": "edit" @@ -56,12 +56,12 @@ ], "launchOptions": { "displayText": "Add", - "moduleName": "@ohri/openmrs-esm-ohri-hiv-app" + "moduleName": "@ohri/openmrs-esm-ohri-hiv-care-treatment-app" }, "formList": [ { - "name": "Partner Notification Form", - "uuid": "8c48efc5-dd85-3795-9f58-8eb436a4edcc" + "name": "PartnerNotificationFormName", + "uuid": "partnerNotificationFormUuid" } ] }, @@ -70,36 +70,36 @@ "hasFilter": false, "headerTitle": "Contact Tracing", "displayText": "Contact Tracing", - "encounterType": "570e9e42-4306-41dc-9bf8-634bbc70a524", + "encounterType": "ContactTracingEncounterType_UUID", "columns": [ { "id": "contactDate", "isDate": true, "title": "Contact Date", - "concept": "160753AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "dateOfEventConcept" }, { "id": "contactMethod", "title": "Contact Method", - "concept": "59c023dd-eed2-4b11-8c34-b88e9439db3c" + "concept": "contactMethodConcept" }, { "id": "contactOutcome", "title": "Contact Outcome", - "concept": "36a3e671-9d60-4109-b41f-046f44f4b389" + "concept": "ContactTracingOutcome_UUID" }, { "id": "actions", "title": "Actions", "actionOptions": [ { - "formName": "Contact Tracing Form", + "formName": "ContactTracingFormName", "package": "hiv-care-treatment", "label": "View Details", "mode": "view" }, { - "formName": "Contact Tracing Form", + "formName": "ContactTracingFormName", "package": "hiv-care-treatment", "label": "Edit Forms", "mode": "edit" @@ -113,8 +113,8 @@ }, "formList": [ { - "name": "Contact Tracing Form", - "uuid": "94a911a8-8da1-3c12-b696-2f3e78c2e87c" + "name": "ContactTracingFormName", + "uuid": "contactTracingFormUuid" } ] } diff --git a/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-config.json b/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-config.json index 103cf29cd..ff1af17f4 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-config.json +++ b/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-config.json @@ -5,50 +5,48 @@ "tabName": "HIV Enrolment", "headerTitle": "HIV Enrolment", "displayText": "HIV Enrolment", - "encounterType": "7e54cd64-f9c3-11eb-8e6a-57478ce139b0", + "encounterType": "careAndTreatmentEncounterType", "columns": [ { "id": "date", "isDate": true, "title": "Enrollment/Re-enrollment Date", - "concept": "20efadf9-86d3-4498-b3ab-7da4dad9c429", - "fallbackConcepts": [ - "160555AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - ] + "concept": "re_enrolmentDateConcept", + "fallbackConcepts": ["enrolmentDate"] }, { "id": "clientDescription", "title": "Patient Type at Enrollment", - "concept": "83e40f2c-c316-43e6-a12e-20a338100281" + "concept": "patientTypeEnrollmentConcept" }, { "id": "dateConfirmedPositive", "isDate": true, "title": "Date Confirmed HIV+", - "concept": "160554AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "dateOfHIVDiagnosisConcept" }, { "id": "entryPoint", "title": "Entry Point", - "concept": "160540AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "entryPointConcept" }, { "id": "populationCategory", "title": "Population Category", - "concept": "166432AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "populationCategoryConcept" }, { "id": "actions", "title": "Actions", "actionOptions": [ { - "formName": "Service Enrolment Form", + "formName": "ServiceEnrolmentFormName", "package": "hiv-care-treatment", "label": "View Details", "mode": "view" }, { - "formName": "Service Enrolment Form", + "formName": "ServiceEnrolmentFormName", "package": "hiv-care-treatment", "label": "Edit Form", "mode": "edit" @@ -58,12 +56,12 @@ ], "launchOptions": { "displayText": "Add", - "moduleName": "@ohri/openmrs-esm-ohri-hiv-app" + "moduleName": "@ohri/openmrs-esm-ohri-hiv-care-treatment-app" }, "formList": [ { - "name": "Service Enrolment Form", - "uuid": "8f713e0e-94a0-3c57-9024-69520933802a" + "name": "ServiceEnrolmentFormName", + "uuid": "serviceEnrolmentFormUuid" } ] }, @@ -71,7 +69,7 @@ "tabName": "ART Therapy", "headerTitle": "ART Therapy", "displayText": "ART Therapy", - "encounterType": "74bf4fe6-8fdb-4228-be39-680a93a9cf6d", + "encounterType": "art_Therapy_EncounterUUID", "columns": [ { "id": "initiationDate", @@ -79,45 +77,47 @@ "title": "Date", "type": "artDate", "conceptMappings": [ - "159599AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", - "162572AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", - "164516AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", - "164431AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", - "160738AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "artTherapyDateTime_UUID", + "artStopDateUUID", + "switchDateUUID", + "substitutionDateUUID", + "dateRestartedUUID" ] }, { "id": "therapyPlan", "title": "Therapy Plan", "type": "artTherapy", - "concept": "7557d77c-172b-4673-9335-67a38657dd01", + "concept": "therapyPlanConcept", "valueMappings": { - "1256AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "Start ART", - "1258AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "Substitute ART Regimen", - "1259AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "Switch ART Regimen Line", - "1260AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "Stop ART", - "3e69cb60-2943-410f-83d4-b359ae83fefd": "Restart ART therapy" + "Start ART": "startART", + "Substitute ART Regimen": "substituteART", + "Switch ART Regimen Line": "switchART", + "Stop ART": "stopART", + "Restart ART therapy": "restartART" } + }, { "id": "regimen", "title": "Regimen", - "concept": "dfbe256e-30ba-4033-837a-2e8477f2e7cd" + "concept": "regimenConcept" }, { "id": "regimenInitiated", "title": "Regimen line", - "concept": "164515AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "regimenLine_UUID" }, { "id": "reason", "title": "Reason", "conceptMappings": [ - "160568AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", - "160562AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", - "163513AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", - "161011AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "switchReasonUUID", + "substituteReasonUUID", + "stopReasonUUID", + "freeTextCommentConcept" ], + "concept": "artTherapyDateTime_UUID", "type": "artReason" }, { @@ -125,13 +125,13 @@ "title": "Actions", "actionOptions": [ { - "formName": "ART Therapy Form", + "formName": "ARTTherapyFormName", "package": "hiv", "label": "View Details", "mode": "view" }, { - "formName": "ART Therapy Form", + "formName": "ARTTherapyFormName", "package": "hiv", "label": "Edit Forms", "mode": "edit" @@ -141,12 +141,12 @@ ], "launchOptions": { "displayText": "Add", - "moduleName": "@ohri/openmrs-esm-ohri-hiv-app" + "moduleName": "@ohri/openmrs-esm-ohri-hiv-care-treatment-app" }, "formList": [ { - "name": "ART Therapy Form", - "uuid": "f99fadd8-feb7-321c-ab58-7569805668e7" + "name": "ARTTherapyFormName", + "uuid": "artTherapyFormUuid" } ] }, @@ -154,36 +154,36 @@ "tabName": "Service Delivery Model", "headerTitle": "Service Delivery Model", "displayText": "Service Delivery Model", - "encounterType": "62ee5922-a229-48d3-a1da-875c1ffa9436", + "encounterType": "ServiceDeliveryEncounterType_UUID", "columns": [ { "id": "vlDate", "isDate": true, "title": "Date", - "concept": "160753AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "dateOfEventConcept" }, { "id": "dsdStatus", "title": "Status", - "concept": "8742967d-8107-4cbb-a17e-9a8c7f624673" + "concept": "DSDStatus_UUID" }, { "id": "dsdModel", "title": "DSD Model", - "concept": "52824cbe-0e4d-4c18-8179-80b5799f34ed" + "concept": "CommunityDSDModel_UUID" }, { "id": "actions", "title": "Actions", "actionOptions": [ { - "formName": "Service Delivery Model Form", + "formName": "ServiceDeliveryFormName", "package": "hiv", "label": "View Details", "mode": "view" }, { - "formName": "Service Delivery Model Form", + "formName": "ServiceDeliveryFormName", "package": "hiv", "label": "Edit Forms", "mode": "edit" @@ -193,12 +193,12 @@ ], "launchOptions": { "displayText": "Add", - "moduleName": "@ohri/openmrs-esm-ohri-hiv-app" + "moduleName": "@ohri/openmrs-esm-ohri-hiv-care-treatment-app" }, "formList": [ { - "name": "Service Delivery Model Form", - "uuid": "1e14f841-b42b-3273-93db-807927ca9a82" + "name": "ServiceDeliveryFormName", + "uuid": "serviceDeliveryFormUuid" } ] }, @@ -206,42 +206,43 @@ "tabName": "Transfer Out", "headerTitle": "Transfer Out", "displayText": "Transfer Out", - "encounterType": "3044916a-7e5f-478b-9091-803233f27f91", + "encounterType": "transferOutEncounterType_UUID", "columns": [ { "id": "visitDate", "isDate": true, "title": "Visit Date", - "concept": "163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "dateOfEncounterConcept" }, { "id": "reasonsForTesting", "title": "Receiving Facility", - "concept": "162724AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "receivingFacility_UUID" }, { "id": "tranferOutDate", "title": "Transfer-Out Date", "isDate": true, - "concept": "160649AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "TransferOutDate_UUID" }, { "id": "verified", "title": "Verified", - "concept": "797e0073-1f3f-46b1-8b1a-8cdad134d2b3" + "isTrueFalseConcept": true, + "concept": "verified_UUID" }, { "id": "actions", "title": "Actions", "actionOptions": [ { - "formName": "Transfer Out Form", + "formName": "TransferOutFormName", "package": "hiv", "label": "View Details", "mode": "view" }, { - "formName": "Transfer Out Form", + "formName": "TransferOutFormName", "package": "hiv", "label": "Edit Forms", "mode": "edit" @@ -251,12 +252,12 @@ ], "launchOptions": { "displayText": "Add", - "moduleName": "@ohri/openmrs-esm-ohri-hiv-app" + "moduleName": "@ohri/openmrs-esm-ohri-hiv-care-treatment-app" }, "formList": [ { - "name": "Transfer Out Form", - "uuid": "a969288d-6605-361b-b01c-42f6ef25c0f5" + "name": "TransferOutFormName", + "uuid": "transferOutFormUuid" } ] }, @@ -264,36 +265,36 @@ "tabName": "Patient Tracing", "headerTitle": "Patient Tracing", "displayText": "Patient Tracing", - "encounterType": "0cd5d4cb-204e-419a-9dd7-1e18e939ce4c", + "encounterType": "PatientTracingEncounterType_UUID", "columns": [ { "id": "contactDate", "isDate": true, "title": "Contact Date", - "concept": "160753AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "dateOfEventConcept" }, { "id": "contactMethod", "title": "Contact Method", - "concept": "59c023dd-eed2-4b11-8c34-b88e9439db3c" + "concept": "contactMethodConcept" }, { "id": "contactOutcome", "title": "Contact Outcome", - "concept": "bc45edbd-11e7-4888-ad7d-4ec3dd8cdcf6" + "concept": "ContactOutcome_UUID" }, { "id": "actions", "title": "Actions", "actionOptions": [ { - "formName": "Patient Tracing Form", + "formName": "PatientTracingFormName", "package": "hiv", "label": "View Details", "mode": "view" }, { - "formName": "Patient Tracing Form", + "formName": "PatientTracingFormName", "package": "hiv", "label": "Edit Forms", "mode": "edit" @@ -303,12 +304,12 @@ ], "launchOptions": { "displayText": "Add", - "moduleName": "@ohri/openmrs-esm-ohri-hiv-app" + "moduleName": "@ohri/openmrs-esm-ohri-hiv-care-treatment-app" }, "formList": [ { - "name": "Patient Tracing Form", - "uuid": "71f3febd-dd11-322b-9c18-2a8a07d87af1" + "name": "PatientTracingFormName", + "uuid": "patientTracingFormUuid" } ] }, @@ -316,41 +317,41 @@ "tabName": "Death", "headerTitle": "Death", "displayText": "Death", - "encounterType": "15272be5-ae9c-4278-a303-4b8907eae73b", + "encounterType": "hivLabResultsEncounterType_UUID", "columns": [ { "id": "deathDate", "isDate": true, "title": "Death Date", - "concept": "1543AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "hivDeathDate_UUID" }, { "id": "deathCause", "title": "Cause of Death", - "concept": "ef973f1f-557f-4620-acf5-9c4c18bf1eda" + "concept": "causeOFDeath_UUID" }, { "id": "specificDeathCause", "title": "Specific cause of Death", - "concept": "e329cdf4-4eeb-4821-85ec-80ec4b503de0" + "concept": "deathSpecific_UUID" }, { "id": "regimenInitiated", "title": "Regimen line", - "concept": "164515AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "regimenLine_UUID" }, { "id": "actions", "title": "Actions", "actionOptions": [ { - "formName": "Death Form", + "formName": "deathFormName", "package": "hiv", "label": "View Details", "mode": "view" }, { - "formName": "Death Form", + "formName": "deathFormName", "package": "hiv", "label": "Edit Forms", "mode": "edit" @@ -364,8 +365,8 @@ }, "formList": [ { - "name": "Death Form", - "uuid": "41af2def-841d-38b7-8d2e-df25bdd0b73f" + "name": "deathFormName", + "uuid": "deathFormUuid" } ] } diff --git a/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-summary.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-summary.component.tsx index fd783cb65..67a4930e3 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-summary.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-summary.component.tsx @@ -3,14 +3,14 @@ import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; import styles from '../common.scss'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import programManagementTabConfigSchema from './program-management-config.json'; +import { configSchema } from '../../config-schema'; interface OverviewListProps { patientUuid: string; } const ProgramManagementSummary: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(programManagementTabConfigSchema); - + const tabs = getMenuItemTabConfiguration(programManagementTabConfigSchema, configSchema); return (
diff --git a/packages/esm-hiv-care-treatment-app/src/views/visits/clinical-visit-config.json b/packages/esm-hiv-care-treatment-app/src/views/visits/clinical-visit-config.json index 735889be8..5795c95b2 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/visits/clinical-visit-config.json +++ b/packages/esm-hiv-care-treatment-app/src/views/visits/clinical-visit-config.json @@ -5,43 +5,43 @@ "tabName": "Clinical Visit", "headerTitle": "Clinical Visit", "displayText": "clinical visit encounters", - "encounterType": "cb0a65a7-0587-477e-89b9-cf2fd144f1d4", + "encounterType": "clinicalVisitEncounterType", "columns": [ { "id": "clinicalVisitDate", "isDate": true, "title": "Visit Date", - "concept": "163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "concept": "dateOfEncounterConcept", "isLink": true }, { "id": "clinicalVisitType", "title": "Visit Type", - "concept": "8a9809e9-8a0b-4e0e-b1f6-80b0cbbe361b" + "concept": "visitTypeConcept" }, { "id": "clinicalScreeningOutcome", "title": "TB Screening Outcome", - "concept": "160108AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "tbScreeningOutcome" }, { "id": "clinicalNextAppointmentDate", "title": "Next Appointment Date", "isDate": true, - "concept": "5096AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "returnVisitDateConcept" }, { "id": "actions", "title": "Actions", "actionOptions": [ { - "formName": "POC Clinical Visit Form v2", + "formName": "ClinicalVisitFormName", "package": "hiv-care-treatment", "label": "View Details", "mode": "view" }, { - "formName": "POC Clinical Visit Form v2", + "formName": "ClinicalVisitFormName", "package": "hiv-care-treatment", "label": "Edit Form", "mode": "edit" @@ -55,8 +55,8 @@ }, "formList": [ { - "name": "POC Clinical Visit Form v2", - "uuid": "b3abc4ce-c5ac-3c40-b8e7-442b163670f1" + "name": "ClinicalVisitFormName", + "uuid": "clinicalVisitFormUuid" } ] } diff --git a/packages/esm-hiv-care-treatment-app/src/views/visits/visits-summary.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/visits/visits-summary.component.tsx index c81f0ab70..eb653a1a7 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/visits/visits-summary.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/visits/visits-summary.component.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import clinicalVisitConfigSchema from './clinical-visit-config.json'; +import { configSchema } from '../../config-schema'; import styles from '../common.scss'; @@ -10,7 +11,7 @@ interface OverviewListProps { } const VisitsSummary: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(clinicalVisitConfigSchema); + const tabs = getMenuItemTabConfiguration(clinicalVisitConfigSchema, configSchema); return (
From 10bd0c7e79f4aada37e6c60e26e8ae90cbb72cf5 Mon Sep 17 00:00:00 2001 From: hadijahkyampeire Date: Tue, 11 Jun 2024 23:57:50 +0300 Subject: [PATCH 2/4] implement the changes in hp and covid jsons --- .../utils/encounter-list-component-util.tsx | 1 + .../utils/encounter-list-config-builder.ts | 42 +------- .../src/utils/schema-manipulation.ts | 48 +++++++++ packages/esm-covid-app/src/config-schema.ts | 10 +- .../case-assessment-schema-config.json | 32 +++--- .../case-assessment.component.tsx | 3 +- .../covid-vaccinations-schema.json | 20 ++-- .../covid-vaccinations.component.tsx | 3 +- .../lab-results-schema-config.json | 102 +++++++++--------- .../patient chart/lab-results.component.tsx | 3 +- .../hts-prevention-schema-config.json | 14 +-- .../hts-prevention-summary.component.tsx | 3 +- 12 files changed, 146 insertions(+), 135 deletions(-) create mode 100644 packages/esm-commons-lib/src/utils/schema-manipulation.ts diff --git a/packages/esm-commons-lib/src/utils/encounter-list-component-util.tsx b/packages/esm-commons-lib/src/utils/encounter-list-component-util.tsx index 41c55de83..b375cd59a 100644 --- a/packages/esm-commons-lib/src/utils/encounter-list-component-util.tsx +++ b/packages/esm-commons-lib/src/utils/encounter-list-component-util.tsx @@ -5,6 +5,7 @@ import { getObsFromEncounter, findObs } from './encounter-list-utils'; export const renderTag = (encounter, concept, statusColorMappings) => { const columnStatus = getObsFromEncounter(encounter, concept); const columnStatusObs = findObs(encounter, concept); + if (columnStatus == '--') { return '--'; } else { diff --git a/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts b/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts index fcbfb32df..7b385af63 100644 --- a/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts +++ b/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts @@ -5,6 +5,7 @@ import { getConceptFromMappings, } from './encounter-list-utils'; import { renderTag } from './encounter-list-component-util'; +import { extractDefaults, replaceWithConfigDefaults } from './schema-manipulation'; interface ConfigSchema { [key: string]: { @@ -152,47 +153,6 @@ export const getTabColumns = (columnsDefinition: Array) => { return columns; }; -function extractDefaults(schema) { - const result = {}; - - function traverse(schema) { - for (const key in schema) { - if (key === '_default') { - Object.assign(result, schema[key]); - } else if (typeof schema[key] === 'object' && !Array.isArray(schema[key])) { - traverse(schema[key]); - } - } - } - - traverse(schema); - return result; -} - -function replaceWithConfigDefaults(obj, configDefaults) { - if (Array.isArray(obj)) { - return obj.map((item) => { - if (typeof item === 'string' && configDefaults.hasOwnProperty(item)) { - return configDefaults[item]; - } else { - return replaceWithConfigDefaults(item, configDefaults); - } - }); - } else if (typeof obj === 'object' && obj !== null) { - const newObj = {}; - for (const key in obj) { - if (typeof obj[key] === 'string' && configDefaults.hasOwnProperty(obj[key])) { - newObj[key] = configDefaults[obj[key]]; - } else { - newObj[key] = replaceWithConfigDefaults(obj[key], configDefaults); - } - } - return newObj; - } else { - return obj; - } -} - export const getMenuItemTabConfiguration = (schemaConfig: MenuProps, configSchema?: ConfigSchema) => { // gonna make the configSchema optional for now until we implement it everywher const configDefaults = extractDefaults(configSchema); diff --git a/packages/esm-commons-lib/src/utils/schema-manipulation.ts b/packages/esm-commons-lib/src/utils/schema-manipulation.ts new file mode 100644 index 000000000..854dd5f85 --- /dev/null +++ b/packages/esm-commons-lib/src/utils/schema-manipulation.ts @@ -0,0 +1,48 @@ +export function extractDefaults(schema) { + const result = {}; + + function traverse(schema) { + for (const key in schema) { + if (key === '_default') { + Object.assign(result, schema[key]); + } else if (typeof schema[key] === 'object' && !Array.isArray(schema[key])) { + traverse(schema[key]); + } + } + } + + traverse(schema); + return result; +} + +export function replaceWithConfigDefaults(obj, configDefaults) { + if (Array.isArray(obj)) { + return obj.map((item) => { + if (typeof item === 'string' && configDefaults.hasOwnProperty(item)) { + return configDefaults[item]; + } else { + return replaceWithConfigDefaults(item, configDefaults); + } + }); + } else if (typeof obj === 'object' && obj !== null) { + const newObj = {}; + for (const key in obj) { + if (typeof obj[key] === 'string') { + if (configDefaults.hasOwnProperty(key)) { + // Case where UUID is the value + newObj[configDefaults[key]] = obj[key]; + } else if (configDefaults.hasOwnProperty(obj[key])) { + // Case where UUID is the key + newObj[key] = configDefaults[obj[key]]; + } else { + newObj[key] = obj[key]; + } + } else { + newObj[key] = replaceWithConfigDefaults(obj[key], configDefaults); + } + } + return newObj; + } else { + return obj; + } +} diff --git a/packages/esm-covid-app/src/config-schema.ts b/packages/esm-covid-app/src/config-schema.ts index 853afe612..17535f111 100644 --- a/packages/esm-covid-app/src/config-schema.ts +++ b/packages/esm-covid-app/src/config-schema.ts @@ -21,10 +21,7 @@ export const configSchema = { covidTypeofTestConcept_UUID: '069f6dfe-88c1-4a45-a894-0d99549c8718', covidSpecimenCollectionDate_UUID: '159951AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', covidOutcomeUUID: 'a845f3e6-4432-4de4-9fff-37fa270b1a06', - covidTestType: '069f6dfe-88c1-4a45-a894-0d99549c8718', - covidOutcome: 'a845f3e6-4432-4de4-9fff-37fa270b1a06', rapidAntigenResultDate: 'af159c77-bc5d-46dd-90d9-bcbffb22267f', - covidTreatementOutConcept_UUID: 'a845f3e6-4432-4de4-9fff-37fa270b1a06', covidRapidTestResultDate_UUID: 'af159c77-bc5d-46dd-90d9-bcbffb22267f', pcrTestResultDate: '4a77ab44-0323-490e-96be-e168c0e5c9de', finalCovid19Result: '5da5c21b-969f-41bd-9091-e40d4c707544', @@ -32,9 +29,7 @@ export const configSchema = { covidDiagnorticPcrResultDate_UUID: '4a77ab44-0323-490e-96be-e168c0e5c9de', htsRetrospectiveEncounterType: '79c1f50f-f77d-42e2-ad2a-d29304dde2fe', htsRetrospectiveType: '79c1f50f-f77d-42e2-ad2a-d29304dde2fe', - pcrTestResult: '3f4ee14b-b4ab-4597-9fe9-406883b63d76', covidReasonsForTestingConcep_UUID: 'ae46f4b1-c15d-4bba-ab41-b9157b82b0ce', - covidDiagnosticPcrResult_UUID: '3f4ee14b-b4ab-4597-9fe9-406883b63d76', covidTestResultUUID: '3f4ee14b-b4ab-4597-9fe9-406883b63d76', covidPatientStatusUUID: 'de3bc9b7-05b5-41b6-a38d-8d2eec646c4f', covidSARS_TestResultConcept_UUID: '89feed9c-1dd9-477a-ab1c-86f5f75f6762', @@ -66,6 +61,10 @@ export const configSchema = { covidVaccineAdministeredConcept_UUID: 'e41fbe17-4aee-4a44-950b-6676d6e0ede2', covidVaccineConcept_UUID: '0cc868bd-e9dd-4b59-b278-f923afe22d82', covidVaccineSeriesConcept_UUID: '45b3959d-f897-4e01-b6e5-16ef6ae0a687', + covidNotDoneStatus: '1118AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', + covidCompletedStatus: '1267AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', + covidCancelledStatus: '165170AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', + covidPendingStatus: '162866AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', }, }, cohorts: { @@ -109,7 +108,6 @@ export const configSchema = { covidLabResultFormUuid: 'cf8cd756-baef-38df-b84d-92968b42c113', covidLabCancellationFormUuid: 'd38bc949-c95b-39eb-a2c5-08b82a36409c', covidSampleCollectionFormUuid: '371d19b6-485f-11ec-99cc-1fdd2d4e9d88', - covidLabOrderFormUuid: 'f5fb6bc4-6fc3-3462-a191-2fff0896bab3', }, }, }; diff --git a/packages/esm-covid-app/src/views/patient chart/case-assessment-schema-config.json b/packages/esm-covid-app/src/views/patient chart/case-assessment-schema-config.json index 6a3440817..4639fc315 100644 --- a/packages/esm-covid-app/src/views/patient chart/case-assessment-schema-config.json +++ b/packages/esm-covid-app/src/views/patient chart/case-assessment-schema-config.json @@ -5,60 +5,60 @@ "tabName": "COVID Assessment", "headerTitle": "COVID Assessment", "displayText": "COVID Assessment", - "encounterType": "253a43d3-c99e-415c-8b78-ee7d4d3c1d54", + "encounterType": "covid_Assessment_EncounterUUID", "columns": [ { "id": "encounterDate", "isDate": true, "title": "Date of Assessment", - "concept": "160753AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "concept": "covidEncounterDateTime_UUID", "isLink": true }, { "id": "reasonsForTesting", "title": "Reason for testing", - "concept": "ae46f4b1-c15d-4bba-ab41-b9157b82b0ce" + "concept": "covidReasonsForTestingConcep_UUID" }, { "id": "symptomatic", "title": "Presentation", - "concept": "de3bc9b7-05b5-41b6-a38d-8d2eec646c4f" + "concept": "covidPatientStatusUUID" }, { "id": "outcome", "title": "Outcome", - "concept": "a845f3e6-4432-4de4-9fff-37fa270b1a06" + "concept": "covidOutcomeUUID" }, { "id": "actions", "title": "Actions", "actionOptions": [ { - "formName": "COVID Case Form", + "formName": "CovidCaseFormName", "package": "covid", "label": "View Case", "mode": "view" }, { - "formName": "COVID Assessment Form", + "formName": "CovidAssessmentFormName", "package": "covid", "label": "View Assessment", "mode": "view" }, { - "formName": "COVID Assessment Form", + "formName": "CovidAssessmentFormName", "package": "covid", "label": "Edit Assessment", "mode": "edit" }, { - "formName": "COVID Case Form", + "formName": "CovidCaseFormName", "package": "covid", "label": "Edit Case", "mode": "edit" }, { - "formName": "COVID Outcome Form", + "formName": "CovidOutcomeFormName", "package": "covid", "label": "Add/Edit Outcome", "mode": "edit" @@ -72,18 +72,18 @@ }, "formList": [ { - "name": "COVID Assessment Form", + "name": "CovidAssessmentFormName", "excludedIntents": ["COVID_LAB_ASSESSMENT_EMBED"], - "uuid": "f5fb6bc4-6fc3-3462-a191-2fff0896bab3" + "uuid": "covidAssessmentFormUuid" }, { - "name": "COVID Case Form", - "uuid": "c0fd71bd-37bc-3c8d-b2ff-149c0ff4d6f0" + "name": "CovidCaseFormName", + "uuid": "covidCaseFormUuid" }, { - "name": "COVID Outcome Form", + "name": "CovidOutcomeFormName", "excludedIntents": ["COVID_OUTCOME_EMBED", "*"], - "uuid": "6515d898-439c-11ec-9103-238295f2dfd7" + "uuid": "covidOutcomeFormUuid" } ] } diff --git a/packages/esm-covid-app/src/views/patient chart/case-assessment.component.tsx b/packages/esm-covid-app/src/views/patient chart/case-assessment.component.tsx index 0b21446b9..a6508a39c 100644 --- a/packages/esm-covid-app/src/views/patient chart/case-assessment.component.tsx +++ b/packages/esm-covid-app/src/views/patient chart/case-assessment.component.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import caseAssessmentSchemaConfig from './case-assessment-schema-config.json'; +import { configSchema } from '../../config-schema'; export const covidFormSlot = 'hts-encounter-form-slot'; export const covidEncounterRepresentation = @@ -13,7 +14,7 @@ interface CovidAssessmentWidgetProps { } const CovidAssessment: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(caseAssessmentSchemaConfig); + const tabs = getMenuItemTabConfiguration(caseAssessmentSchemaConfig, configSchema); return ( <> diff --git a/packages/esm-covid-app/src/views/patient chart/covid-vaccinations-schema.json b/packages/esm-covid-app/src/views/patient chart/covid-vaccinations-schema.json index a407b2dd7..73be320a0 100644 --- a/packages/esm-covid-app/src/views/patient chart/covid-vaccinations-schema.json +++ b/packages/esm-covid-app/src/views/patient chart/covid-vaccinations-schema.json @@ -5,42 +5,42 @@ "tabName": "Vaccinations", "headerTitle": "Vaccinations", "displayText": "Vaccinations", - "encounterType": "5b37ce7a-c55e-4226-bdc8-5af04025a6de", + "encounterType": "covidVaccinationEncounterUUID", "columns": [ { "id": "vaccinationDate", "isDate": true, "title": "Vaccination Date", - "concept": "1410AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "covidVaccinationAdministeredConcept_UUID" }, { "id": "doseAdministered", "title": "Vaccine Dose", - "concept": "6ec64cb3-e710-4d3e-9db4-38c135966a45" + "concept": "covidVaccinationDose_UUID" }, { "id": "vaccineSeries", "title": "Vaccine Series", - "concept": "45b3959d-f897-4e01-b6e5-16ef6ae0a687" + "concept": "covidVaccineSeriesConcept_UUID" }, { "id": "covidVaccineType", "title": "Vaccine Administered", - "concept": "e41fbe17-4aee-4a44-950b-6676d6e0ede2", - "secondaryConcept": "0cc868bd-e9dd-4b59-b278-f923afe22d82" + "concept": "covidVaccineAdministeredConcept_UUID", + "secondaryConcept": "covidVaccineConcept_UUID" }, { "id": "actions", "title": "Actions", "actionOptions": [ { - "formName": "COVID Vaccination Form", + "formName": "CovidVaccinationFormName", "package": "covid", "label": "View Details", "mode": "view" }, { - "formName": "COVID Vaccination Form", + "formName": "CovidVaccinationFormName", "package": "covid", "label": "Edit Form", "mode": "edit" @@ -54,8 +54,8 @@ }, "formList": [ { - "name": "COVID Vaccination Form", - "uuid": "3ae3a031-2e24-357d-81b3-205d5187090a" + "name": "CovidVaccinationFormName", + "uuid": "covidVaccinationFormUuid" } ] } diff --git a/packages/esm-covid-app/src/views/patient chart/covid-vaccinations.component.tsx b/packages/esm-covid-app/src/views/patient chart/covid-vaccinations.component.tsx index 11de826dc..9e982c280 100644 --- a/packages/esm-covid-app/src/views/patient chart/covid-vaccinations.component.tsx +++ b/packages/esm-covid-app/src/views/patient chart/covid-vaccinations.component.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import covidVaccinationsSchemaConfig from './covid-vaccinations-schema.json'; +import { configSchema } from '../../config-schema'; interface CovidVaccinationsWidgetProps { patientUuid: string; @@ -10,7 +11,7 @@ interface CovidVaccinationsWidgetProps { export const covidFormSlot = 'hts-encounter-form-slot'; const CovidVaccinations: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(covidVaccinationsSchemaConfig); + const tabs = getMenuItemTabConfiguration(covidVaccinationsSchemaConfig, configSchema); return ( <> diff --git a/packages/esm-covid-app/src/views/patient chart/lab-results-schema-config.json b/packages/esm-covid-app/src/views/patient chart/lab-results-schema-config.json index ba77b5266..520529e9c 100644 --- a/packages/esm-covid-app/src/views/patient chart/lab-results-schema-config.json +++ b/packages/esm-covid-app/src/views/patient chart/lab-results-schema-config.json @@ -5,47 +5,47 @@ "tabName": "Lab Tests", "headerTitle": "Lab Tests", "displayText": "Lab Tests", - "encounterType": "a77d3e7f-5c8f-4074-a207-77a70e197b0c", + "encounterType": "covidLabOrderEncounterType_UUID", "columns": [ { "id": "orderDate", "isDate": true, "title": "Date of Order", - "concept": "162078AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "covidLabOrderDate_UUID" }, { "id": "reasonsForTesting", "title": "Reason for testing", - "concept": "ae46f4b1-c15d-4bba-ab41-b9157b82b0ce" + "concept": "covidReasonsForTestingConcep_UUID" }, { "id": "testType", "title": "Test Type", - "concept": "069f6dfe-88c1-4a45-a894-0d99549c8718" + "concept": "covidTypeofTestConcept_UUID" }, { "id": "labStatus", "title": "Status", - "concept": "6681366c-2174-489a-b951-13a1404935bf", + "concept": "covidTestStatusConcept_UUID", "type": "tag", "statusColorMappings": { - "1118AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "green", - "1267AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "green", - "165170AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "purple", - "162866AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "blue" + "covidNotDoneStatus": "green", + "covidCompletedStatus": "green", + "covidCancelledStatus": "purple", + "covidPendingStatus": "blue" } }, { "id": "labTestResult", "title": "Test Result", - "concept": "3f4ee14b-b4ab-4597-9fe9-406883b63d76", - "fallbackConcepts": ["cbcbb029-f11f-4437-9d53-1d0f0a170433"] + "concept": "covidTestResultUUID", + "fallbackConcepts": ["rapidTestResult"] }, { "id": "testResultDate", "isDate": true, "title": "Date of Test Result", - "concept": "163724AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "covidTestResultDate_UUID" }, { @@ -53,13 +53,13 @@ "title": "Actions", "actionOptions": [ { - "formName": "COVID Lab Test", + "formName": "CovidLabTestFormName", "package": "covid", "label": "View Details", "mode": "view" }, { - "formName": "COVID Lab Test", + "formName": "CovidLabTestFormName", "package": "covid", "label": "Add/Edit Lab Result", "mode": "edit" @@ -67,20 +67,20 @@ ], "conditionalActionOptions": [ { - "formName": "Lab Order Cancellation", + "formName": "CovidLabCancellationFormName", "package": "covid", "label": "Cancel Lab order", "mode": "edit", "dependsOn": "Pending", - "dependantConcept": "6681366c-2174-489a-b951-13a1404935bf" + "dependantConcept": "covidTestStatusConcept_UUID" }, { - "formName": "Sample Collection", + "formName": "CovidSampleCollectionFormName", "package": "covid", "label": "Collect Sample", "mode": "edit", "dependsOn": "Pending", - "dependantConcept": "6681366c-2174-489a-b951-13a1404935bf" + "dependantConcept": "covidTestStatusConcept_UUID" } ] } @@ -91,29 +91,29 @@ }, "formList": [ { - "name": "COVID Lab Order Form", + "name": "CovidLabOrderFormName", "excludedIntents": ["COVID_LAB_ORDER_EMBED"], - "uuid": "f5fb6bc4-6fc3-3462-a191-2fff0896bab3" + "uuid": "covidAssessmentFormUuid" }, { - "name": "COVID Lab Result Form", + "name": "CovidLabResultFormName", "excludedIntents": ["COVID_LAB_RESULT_EMBED"], - "uuid": "cf8cd756-baef-38df-b84d-92968b42c113" + "uuid": "covidLabResultFormUuid" }, { - "name": "COVID Lab Test", + "name": "CovidLabTestFormName", "excludedIntents": ["*"], - "uuid": "e92fe922-4863-11ec-99cc-1fdd2d4e9d88" + "uuid": "covidLabTestFormUuid" }, { - "name": "Lab Order Cancellation", + "name": "CovidLabCancellationFormName", "excludedIntents": ["*", "COVID_LAB_CANCELLATION_EMBED"], - "uuid": "d38bc949-c95b-39eb-a2c5-08b82a36409c" + "uuid": "covidLabCancellationFormUuid" }, { - "name": "Sample Collection", + "name": "CovidSampleCollectionFormName", "excludedIntents": ["*", "COVID_SAMPLE_COLLECTION_EMBED"], - "uuid": "371d19b6-485f-11ec-99cc-1fdd2d4e9d88" + "uuid": "covidSampleCollectionFormUuid" } ] }, @@ -121,34 +121,34 @@ "tabName": "Pending Lab Orders", "headerTitle": "Pending Lab Orders", "displayText": "Pending Lab Orders", - "encounterType": "a77d3e7f-5c8f-4074-a207-77a70e197b0c", + "encounterType": "covidLabOrderEncounterType_UUID", "columns": [ { "id": "orderDate", "isDate": true, "title": "Date of Order", - "concept": "162078AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "covidLabOrderDate_UUID" }, { "id": "testType", "title": "Test Type", - "concept": "069f6dfe-88c1-4a45-a894-0d99549c8718" + "concept": "covidTypeofTestConcept_UUID" }, { "id": "fowardLabreference", "title": "Fowarded to Reference Lab", - "concept": "161934AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "covidTestResultConcept_UUID" }, { "id": "labStatus", "title": "Status", - "concept": "6681366c-2174-489a-b951-13a1404935bf", + "concept": "covidTestStatusConcept_UUID", "type": "tag", "statusColorMappings": { - "1118AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "green", - "1267AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "green", - "165170AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "purple", - "162866AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA": "blue" + "covidNotDoneStatus": "green", + "covidCompletedStatus": "green", + "covidCancelledStatus": "purple", + "covidPendingStatus": "blue" } }, { @@ -156,19 +156,19 @@ "title": "Actions", "actionOptions": [ { - "formName": "COVID Lab Test", + "formName": "CovidLabTestFormName", "package": "covid", "label": "View Details", "mode": "view" }, { - "formName": "Sample Collection", + "formName": "CovidSampleCollectionFormName", "package": "covid", "label": "Collect Sample", "mode": "edit" }, { - "formName": "COVID Lab Result Form", + "formName": "CovidLabResultFormName", "package": "covid", "label": "Add/Edit Lab Result", "mode": "edit" @@ -178,29 +178,29 @@ ], "launchOptions": { "displayText": "Add", - "moduleName": "@ohri/openmrs-esm-covid-app", + "moduleName": "@ohri/openmrs-esm-ohri-covid-app", "hideFormLauncher": true }, "formList": [ { - "name": "COVID Lab Test", - "uuid": "e92fe922-4863-11ec-99cc-1fdd2d4e9d88" + "name": "CovidLabTestFormName", + "uuid": "covidLabTestFormUuid" }, { - "name": "COVID Lab Result Form", - "uuid": "cf8cd756-baef-38df-b84d-92968b42c113" + "name": "CovidLabResultFormName", + "uuid": "covidLabResultFormUuid" }, { - "name": "Lab Order Cancellation", - "uuid": "d38bc949-c95b-39eb-a2c5-08b82a36409c" + "name": "CovidLabCancellationFormName", + "uuid": "covidLabCancellationFormUuid" }, { - "name": "Sample Collection", - "uuid": "371d19b6-485f-11ec-99cc-1fdd2d4e9d88" + "name": "CovidSampleCollectionFormName", + "uuid": "covidSampleCollectionFormUuid" }, { - "name": "COVID Lab Order Form", - "uuid": "f5fb6bc4-6fc3-3462-a191-2fff0896bab3" + "name": "CovidLabOrderFormName", + "uuid": "covidAssessmentFormUuid" } ], "hasFilter": true diff --git a/packages/esm-covid-app/src/views/patient chart/lab-results.component.tsx b/packages/esm-covid-app/src/views/patient chart/lab-results.component.tsx index 84ee08630..05fd80bb1 100644 --- a/packages/esm-covid-app/src/views/patient chart/lab-results.component.tsx +++ b/packages/esm-covid-app/src/views/patient chart/lab-results.component.tsx @@ -4,6 +4,7 @@ import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; import { EncounterList, getObsFromEncounter, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import { useConfig } from '@openmrs/esm-framework'; import covidLabTestSchemaConfig from './lab-results-schema-config.json'; +import { configSchema } from '../../config-schema'; export const covidFormSlot = 'hts-encounter-form-slot'; export const covidEncounterRepresentation = @@ -18,7 +19,7 @@ interface CovidLabWidgetProps { const CovidLabResults: React.FC = ({ patientUuid }) => { const config = useConfig(); - const tabs = getMenuItemTabConfiguration(covidLabTestSchemaConfig); + const tabs = getMenuItemTabConfiguration(covidLabTestSchemaConfig, configSchema); let pendingLabOrdersFilter = (encounter) => { return getObsFromEncounter(encounter, config.obsConcepts.covidTestStatusConcept_UUID) === 'Pending'; diff --git a/packages/esm-hiv-prevention-app/src/views/hiv-testing-services/hts-prevention-schema-config.json b/packages/esm-hiv-prevention-app/src/views/hiv-testing-services/hts-prevention-schema-config.json index 3c96055d8..0f563ad7f 100644 --- a/packages/esm-hiv-prevention-app/src/views/hiv-testing-services/hts-prevention-schema-config.json +++ b/packages/esm-hiv-prevention-app/src/views/hiv-testing-services/hts-prevention-schema-config.json @@ -5,13 +5,13 @@ "tabName": "HIV Testing", "headerTitle": "HIV Testing", "displayText": "HIV Testing", - "encounterType": "79c1f50f-f77d-42e2-ad2a-d29304dde2fe", + "encounterType": "htsRetrospectiveEncounterType", "columns": [ { "id": "date", "isDate": true, "title": "Date of HIV Test", - "concept": "164400AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "concept": "dateOfHIVTestingConceptUUID" }, { "id": "location", @@ -21,7 +21,7 @@ { "id": "hivTestResult", "title": "HIV Test result", - "concept": "e16b0068-b6a2-46b7-aba9-e3be00a7b4ab" + "concept": "hivTestResultConceptUUID" }, { "id": "provider", @@ -33,13 +33,13 @@ "title": "Actions", "actionOptions": [ { - "formName": "HIV Testing", + "formName": "HIVTestingFormName", "package": "hiv-prevention", "label": "View Details", "mode": "view" }, { - "formName": "HIV Testing", + "formName": "HIVTestingFormName", "package": "hiv-prevention", "label": "Edit Form", "mode": "edit" @@ -53,8 +53,8 @@ }, "formList": [ { - "name": "HIV Testing", - "uuid": "43ffea77-49dc-3ebd-8d83-c2aedb654030", + "name": "HIVTestingFormName", + "uuid": "hivTestingFormUuid", "excludedIntents": ["HTS_PRE_TEST", "HTS_TEST", "HTS_POST_TEST"], "fixedIntent": "*" } diff --git a/packages/esm-hiv-prevention-app/src/views/hiv-testing-services/hts-prevention-summary.component.tsx b/packages/esm-hiv-prevention-app/src/views/hiv-testing-services/hts-prevention-summary.component.tsx index f82a67c1b..14ef94f0c 100644 --- a/packages/esm-hiv-prevention-app/src/views/hiv-testing-services/hts-prevention-summary.component.tsx +++ b/packages/esm-hiv-prevention-app/src/views/hiv-testing-services/hts-prevention-summary.component.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import htsTestingSchemaConfig from './hts-prevention-schema-config.json'; +import { configSchema } from '../../config-schema'; import styles from '../common.scss'; @@ -10,7 +11,7 @@ interface OverviewListProps { } const HTSPreventionSummary: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(htsTestingSchemaConfig); + const tabs = getMenuItemTabConfiguration(htsTestingSchemaConfig, configSchema); return (
From 6a6472a2de4e96df5b9e104c9e12d56dd60d7be1 Mon Sep 17 00:00:00 2001 From: hadijahkyampeire Date: Wed, 12 Jun 2024 13:14:11 +0300 Subject: [PATCH 3/4] fix the missing concept --- .../views/general-counselling/general-conselling-config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-conselling-config.json b/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-conselling-config.json index ac65602b7..e46432ec3 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-conselling-config.json +++ b/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-conselling-config.json @@ -119,7 +119,7 @@ "formList": [ { "name": "IntimatePartnerFormName", - "uuid": "5c37314f-c558-3720-8780-d123c70f4e23" + "uuid": "intimatePartnerFormUuid" } ] }, From 16d8740ef953725a8b4207ff81e5b3cda5c55026 Mon Sep 17 00:00:00 2001 From: hadijahkyampeire Date: Thu, 13 Jun 2024 13:13:38 +0300 Subject: [PATCH 4/4] use the schema from the framework instead of importing manually --- .../src/utils/encounter-list-config-builder.ts | 12 +++--------- .../src/utils/encounter-list-utils.ts | 2 +- .../src/utils/schema-manipulation.ts | 17 ++++++++--------- .../patient chart/case-assessment.component.tsx | 4 +++- .../covid-vaccinations.component.tsx | 4 +++- .../patient chart/lab-results.component.tsx | 6 +++--- .../general-counselling-summary.component.tsx | 5 +++-- .../partner-notification-services.component.tsx | 12 ++++-------- .../program-management-summary.component.tsx | 9 ++++++--- .../views/visits/visits-summary.component.tsx | 6 ++++-- .../hts-prevention-summary.component.tsx | 5 +++-- 11 files changed, 41 insertions(+), 41 deletions(-) diff --git a/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts b/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts index 7b385af63..9fd483494 100644 --- a/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts +++ b/packages/esm-commons-lib/src/utils/encounter-list-config-builder.ts @@ -5,16 +5,10 @@ import { getConceptFromMappings, } from './encounter-list-utils'; import { renderTag } from './encounter-list-component-util'; -import { extractDefaults, replaceWithConfigDefaults } from './schema-manipulation'; +import { extractSchemaValues, replaceWithConfigDefaults } from './schema-manipulation'; interface ConfigSchema { - [key: string]: { - _type: unknown; - _description: string; - _default: { - [key: string]: string; - }; - }; + [key: string]: { [key: string]: string | Array }; } interface MenuProps { @@ -155,7 +149,7 @@ export const getTabColumns = (columnsDefinition: Array) => { export const getMenuItemTabConfiguration = (schemaConfig: MenuProps, configSchema?: ConfigSchema) => { // gonna make the configSchema optional for now until we implement it everywher - const configDefaults = extractDefaults(configSchema); + const configDefaults = extractSchemaValues(configSchema); const transformedSchemaConfig = replaceWithConfigDefaults(schemaConfig, configDefaults); diff --git a/packages/esm-commons-lib/src/utils/encounter-list-utils.ts b/packages/esm-commons-lib/src/utils/encounter-list-utils.ts index a844321b6..09f696714 100644 --- a/packages/esm-commons-lib/src/utils/encounter-list-utils.ts +++ b/packages/esm-commons-lib/src/utils/encounter-list-utils.ts @@ -32,7 +32,7 @@ export function getObsFromEncounters(encounters, obsConcept) { export function resolveValueUsingMappings(encounter, concept, mappings) { const obs = findObs(encounter, concept); for (const key in mappings) { - if (mappings[key] === obs.value.uuid) { + if (mappings[key] === obs?.value?.uuid) { return key; } } diff --git a/packages/esm-commons-lib/src/utils/schema-manipulation.ts b/packages/esm-commons-lib/src/utils/schema-manipulation.ts index 854dd5f85..3c68a1ec2 100644 --- a/packages/esm-commons-lib/src/utils/schema-manipulation.ts +++ b/packages/esm-commons-lib/src/utils/schema-manipulation.ts @@ -1,14 +1,13 @@ -export function extractDefaults(schema) { +export function extractSchemaValues(schema) { const result = {}; - - function traverse(schema) { - for (const key in schema) { - if (key === '_default') { - Object.assign(result, schema[key]); - } else if (typeof schema[key] === 'object' && !Array.isArray(schema[key])) { - traverse(schema[key]); + function traverse(obj) { + Object.entries(obj).forEach(([key, value]) => { + if (typeof value === 'object' && !Array.isArray(value)) { + traverse(value); + } else { + result[key] = value; } - } + }); } traverse(schema); diff --git a/packages/esm-covid-app/src/views/patient chart/case-assessment.component.tsx b/packages/esm-covid-app/src/views/patient chart/case-assessment.component.tsx index a6508a39c..db0e3f577 100644 --- a/packages/esm-covid-app/src/views/patient chart/case-assessment.component.tsx +++ b/packages/esm-covid-app/src/views/patient chart/case-assessment.component.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import { useConfig } from '@openmrs/esm-framework'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import caseAssessmentSchemaConfig from './case-assessment-schema-config.json'; import { configSchema } from '../../config-schema'; @@ -14,7 +15,8 @@ interface CovidAssessmentWidgetProps { } const CovidAssessment: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(caseAssessmentSchemaConfig, configSchema); + const config = useConfig(); + const tabs = getMenuItemTabConfiguration(caseAssessmentSchemaConfig, config); return ( <> diff --git a/packages/esm-covid-app/src/views/patient chart/covid-vaccinations.component.tsx b/packages/esm-covid-app/src/views/patient chart/covid-vaccinations.component.tsx index 9e982c280..0c46bf90d 100644 --- a/packages/esm-covid-app/src/views/patient chart/covid-vaccinations.component.tsx +++ b/packages/esm-covid-app/src/views/patient chart/covid-vaccinations.component.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import { useConfig } from '@openmrs/esm-framework'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import covidVaccinationsSchemaConfig from './covid-vaccinations-schema.json'; @@ -11,7 +12,8 @@ interface CovidVaccinationsWidgetProps { export const covidFormSlot = 'hts-encounter-form-slot'; const CovidVaccinations: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(covidVaccinationsSchemaConfig, configSchema); + const config = useConfig(); + const tabs = getMenuItemTabConfiguration(covidVaccinationsSchemaConfig, config); return ( <> diff --git a/packages/esm-covid-app/src/views/patient chart/lab-results.component.tsx b/packages/esm-covid-app/src/views/patient chart/lab-results.component.tsx index 05fd80bb1..f40b70ac6 100644 --- a/packages/esm-covid-app/src/views/patient chart/lab-results.component.tsx +++ b/packages/esm-covid-app/src/views/patient chart/lab-results.component.tsx @@ -1,10 +1,10 @@ import React from 'react'; -import styles from './covid.scss'; import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; import { EncounterList, getObsFromEncounter, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import { useConfig } from '@openmrs/esm-framework'; import covidLabTestSchemaConfig from './lab-results-schema-config.json'; -import { configSchema } from '../../config-schema'; + +import styles from './covid.scss'; export const covidFormSlot = 'hts-encounter-form-slot'; export const covidEncounterRepresentation = @@ -19,7 +19,7 @@ interface CovidLabWidgetProps { const CovidLabResults: React.FC = ({ patientUuid }) => { const config = useConfig(); - const tabs = getMenuItemTabConfiguration(covidLabTestSchemaConfig, configSchema); + const tabs = getMenuItemTabConfiguration(covidLabTestSchemaConfig, config); let pendingLabOrdersFilter = (encounter) => { return getObsFromEncounter(encounter, config.obsConcepts.covidTestStatusConcept_UUID) === 'Pending'; diff --git a/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-counselling-summary.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-counselling-summary.component.tsx index 51ebf6bf8..5c0cd7506 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-counselling-summary.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/general-counselling/general-counselling-summary.component.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; +import { useConfig } from '@openmrs/esm-framework'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import generalConsellingConfigSchema from './general-conselling-config.json'; -import { configSchema } from '../../config-schema'; import styles from '../common.scss'; @@ -11,7 +11,8 @@ interface OverviewListProps { } const GeneralCounsellingSummary: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(generalConsellingConfigSchema, configSchema); + const config = useConfig(); + const tabs = getMenuItemTabConfiguration(generalConsellingConfigSchema, config); const tabFilter = (encounter, formName) => { return encounter?.form?.name === formName; diff --git a/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/partner-notification-services.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/partner-notification-services.component.tsx index 36beacd01..ac41990af 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/partner-notification-services.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/partner-notification-services/partner-notification-services.component.tsx @@ -1,13 +1,8 @@ import React from 'react'; import { Tabs, Tab, TabList, TabPanels, TabPanel, Tag } from '@carbon/react'; -import { - EncounterList, - getMenuItemTabConfiguration, - getObsFromEncounter, - findObs, -} from '@ohri/openmrs-esm-ohri-commons-lib'; +import { useConfig } from '@openmrs/esm-framework'; +import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import partnerNotificationsConfigSchema from './patner-notification-config.json'; -import { configSchema } from '../../config-schema'; import styles from '../common.scss'; @@ -16,7 +11,8 @@ interface OverviewListProps { } const PartnerNotificationServices: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(partnerNotificationsConfigSchema, configSchema); + const config = useConfig(); + const tabs = getMenuItemTabConfiguration(partnerNotificationsConfigSchema, config); const tabFilter = (encounter, formName) => { return encounter?.form?.name === formName; diff --git a/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-summary.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-summary.component.tsx index 67a4930e3..bf425d6c0 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-summary.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/program-management/program-management-summary.component.tsx @@ -1,16 +1,19 @@ import React from 'react'; import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; -import styles from '../common.scss'; +import { useConfig } from '@openmrs/esm-framework'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import programManagementTabConfigSchema from './program-management-config.json'; -import { configSchema } from '../../config-schema'; + +import styles from '../common.scss'; interface OverviewListProps { patientUuid: string; } const ProgramManagementSummary: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(programManagementTabConfigSchema, configSchema); + const config = useConfig(); + const tabs = getMenuItemTabConfiguration(programManagementTabConfigSchema, config); + return (
diff --git a/packages/esm-hiv-care-treatment-app/src/views/visits/visits-summary.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/visits/visits-summary.component.tsx index eb653a1a7..7c6d96805 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/visits/visits-summary.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/visits/visits-summary.component.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; +import { useConfig } from '@openmrs/esm-framework'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import clinicalVisitConfigSchema from './clinical-visit-config.json'; -import { configSchema } from '../../config-schema'; import styles from '../common.scss'; @@ -11,7 +11,9 @@ interface OverviewListProps { } const VisitsSummary: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(clinicalVisitConfigSchema, configSchema); + const config = useConfig(); + const tabs = getMenuItemTabConfiguration(clinicalVisitConfigSchema, config); + return (
diff --git a/packages/esm-hiv-prevention-app/src/views/hiv-testing-services/hts-prevention-summary.component.tsx b/packages/esm-hiv-prevention-app/src/views/hiv-testing-services/hts-prevention-summary.component.tsx index 14ef94f0c..dff33912d 100644 --- a/packages/esm-hiv-prevention-app/src/views/hiv-testing-services/hts-prevention-summary.component.tsx +++ b/packages/esm-hiv-prevention-app/src/views/hiv-testing-services/hts-prevention-summary.component.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { Tabs, Tab, TabList, TabPanels, TabPanel } from '@carbon/react'; +import { useConfig } from '@openmrs/esm-framework'; import { EncounterList, getMenuItemTabConfiguration } from '@ohri/openmrs-esm-ohri-commons-lib'; import htsTestingSchemaConfig from './hts-prevention-schema-config.json'; -import { configSchema } from '../../config-schema'; import styles from '../common.scss'; @@ -11,7 +11,8 @@ interface OverviewListProps { } const HTSPreventionSummary: React.FC = ({ patientUuid }) => { - const tabs = getMenuItemTabConfiguration(htsTestingSchemaConfig, configSchema); + const config = useConfig(); + const tabs = getMenuItemTabConfiguration(htsTestingSchemaConfig, config); return (